sequelize-typescript-migration-engine
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.6 • Public • Published

    sequelize typescript migration engine

    // Fist migration file in `migrations` directory. `2021_01_01.ts`
    import { QueryInterface, Transaction } from "sequelize/types";
    export async function up(queryInterface: QueryInterface, transaction: Transaction) {
        await queryInterface.sequelize.query(`
            CREATE TABLE IF NOT EXISTS "project" (
                "id"   SERIAL,
                "name" VARCHAR(255),
                "createdAt" TIMESTAMP WITH TIME ZONE NOT NULL,
                "updatedAt" TIMESTAMP WITH TIME ZONE NOT NULL,
                PRIMARY KEY ("id")
            );
        `, { transaction });
    }
    export async function down(queryInterface: QueryInterface, transaction: Transaction) {
        await queryInterface.dropTable('project', { transaction });
    }
    // Second migration file in `migrations` directory. `2021_01_02.ts`
    import { DataTypes } from 'sequelize';
    import { QueryInterface, Transaction } from "sequelize/types";
    export async function up(queryInterface: QueryInterface, transaction: Transaction) {
        await queryInterface.addColumn('project', 'description', {
            type: DataTypes.STRING,
        }, { transaction });
    }
    export async function down(queryInterface: QueryInterface, transaction: Transaction) {
        await queryInterface.removeColumn('project', 'description', { transaction });
    }
    import path from 'path';
    import {MigrationEngine} from 'sequelize-typescript-migration-engine';
    
    const migrationFolder = path.join(__dirname, 'migrations');
    const engine = new MigratorEngine(sequelize, migrationFolder, '2021_01_02');
    
    await engine.init();

    Hotfix to create sequelize-typescript-migration-engine.d.ts file

    Install

    npm i sequelize-typescript-migration-engine

    DownloadsWeekly Downloads

    5

    Version

    0.0.6

    License

    MIT

    Unpacked Size

    224 kB

    Total Files

    13

    Last publish

    Collaborators

    • feyzullahyildiz