safeql icon indicating copy to clipboard operation
safeql copied to clipboard

Support TypeORM format migrations

Open fingeromer opened this issue 2 years ago • 2 comments

Today SafeQL supports only raw SQL migration files. (In the migrationsDir)

As a TypeORM user, I would like to also have a support of TS migrations files. Their structure simple:

import { MigrationInterface, QueryRunner } from 'typeorm';

export class MigrationTIMESTAMP implements MigrationInterface {
  name = 'MigrationsTIMESTAMP';

  public async up(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(
      `ALTER TABLE "foo" ADD "bar" boolean NOT NULL DEFAULT false`,
    );
  }

  public async down(queryRunner: QueryRunner): Promise<void> {
    await queryRunner.query(`ALTER TABLE "foo" DROP COLUMN "bar"`);
  }
}

My team would also like to help and contribute to this project by developing this feature :)

fingeromer avatar Jun 24 '23 18:06 fingeromer

I'm working on something that should help integrate libraries-specific syntax (such as SQL fragments). Maybe I should widen it so each integration will be able to handle its own migration logic as well.

Newbie012 avatar Jun 27 '23 12:06 Newbie012

@fingeromer sorry for intruding here, but could you share how you've setup incremental adoption using https://safeql.dev/advanced/incremental-adoption.html? (https://github.com/ts-safeql/safeql/issues/185)

simplenotezy avatar Oct 18 '23 11:10 simplenotezy