salsita / node-pg-migrate

Node.js database migration management for PostgreSQL
https://salsita.github.io/node-pg-migrate
MIT License
1.29k stars 177 forks source link

Generating initial TypeScript migration file based on existing schema. #1268

Open ayazemregm opened 1 month ago

ayazemregm commented 1 month ago

I took a quick look to docs but I could not find how to do schema diff. If I want to integrate this to already existing dbs do I need to write everything again or am I missing something?

Shinigami92 commented 1 month ago

You talking about something like #275?

ayazemre commented 1 month ago

Yes but for typescript generations, not sql if possible. Also I am having hard time to use CLI.

{
    "db": {
        "url": "postgres://postgres:123456@localhost:3002/postgres"
    },
    "schema": "public",
    "createSchema": false,
    "migrationsDir": "migrations",
    "migrationsSchema": "public",
    "createMigrationsSchema": false,
    "migrationsTable": "pgmigrations",
    "migrationFilenameFormat": "utc",
    "migrationFileLanguage": "js",
    "checkOrder": true,
    "verbose": true,
    "decamelize": false,
    "tsconfig": "tsconfig.json"
}

This is my test config

I run npx node-pg-migrate -f ./pgm-config.json up and it tries to connect 5432 not 3002. Also it does not reference migration paths as well. When I change file name it gives error meaning it reads the file just does not apply the settings. I am probably missing something too obvious but wanted to ask here.

Shinigami92 commented 1 month ago

Please open dedicated issues for each separate issue you have, so I can better prioritize them and they don't get lost.

Shinigami92 commented 1 month ago

You should adjust the title to e.g. Generating initial TypeScript migration file based on existing schema.

However, I think this will be a really huge task if not even impossible (because of hundreds of edge-cases) But feel free to try a PR 🤷