import { Migration } from '@mikro-orm/migrations';

export class Migration20240415223053 extends Migration {

  async up(): Promise<void> {
    this.addSql('alter table "app" alter column "created_at" type timestamptz using ("created_at"::timestamptz);');
    this.addSql('alter table "app" alter column "updated_at" type timestamptz using ("updated_at"::timestamptz);');

    this.addSql('alter table "tenant" alter column "created_at" type timestamptz using ("created_at"::timestamptz);');
    this.addSql('alter table "tenant" alter column "updated_at" type timestamptz using ("updated_at"::timestamptz);');

    this.addSql('alter table "user" alter column "created_at" type timestamptz using ("created_at"::timestamptz);');
    this.addSql('alter table "user" alter column "updated_at" type timestamptz using ("updated_at"::timestamptz);');

    this.addSql('alter table "tenant_app" alter column "created_at" type timestamptz using ("created_at"::timestamptz);');
    this.addSql('alter table "tenant_app" alter column "updated_at" type timestamptz using ("updated_at"::timestamptz);');

    this.addSql('alter table "apikey" alter column "created_at" type timestamptz using ("created_at"::timestamptz);');
    this.addSql('alter table "apikey" alter column "updated_at" type timestamptz using ("updated_at"::timestamptz);');

    this.addSql('alter table "user_role" alter column "created_at" type timestamptz using ("created_at"::timestamptz);');
    this.addSql('alter table "user_role" alter column "updated_at" type timestamptz using ("updated_at"::timestamptz);');
  }

  async down(): Promise<void> {
    this.addSql('alter table "app" alter column "created_at" type jsonb using ("created_at"::jsonb);');
    this.addSql('alter table "app" alter column "updated_at" type jsonb using ("updated_at"::jsonb);');

    this.addSql('alter table "tenant" alter column "created_at" type jsonb using ("created_at"::jsonb);');
    this.addSql('alter table "tenant" alter column "updated_at" type jsonb using ("updated_at"::jsonb);');

    this.addSql('alter table "user" alter column "created_at" type jsonb using ("created_at"::jsonb);');
    this.addSql('alter table "user" alter column "updated_at" type jsonb using ("updated_at"::jsonb);');

    this.addSql('alter table "tenant_app" alter column "created_at" type jsonb using ("created_at"::jsonb);');
    this.addSql('alter table "tenant_app" alter column "updated_at" type jsonb using ("updated_at"::jsonb);');

    this.addSql('alter table "apikey" alter column "created_at" type jsonb using ("created_at"::jsonb);');
    this.addSql('alter table "apikey" alter column "updated_at" type jsonb using ("updated_at"::jsonb);');

    this.addSql('alter table "user_role" alter column "created_at" type jsonb using ("created_at"::jsonb);');
    this.addSql('alter table "user_role" alter column "updated_at" type jsonb using ("updated_at"::jsonb);');
  }

}
