Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pg] add migrationsTable config support for migration #1638

Conversation

g3r4n
Copy link
Contributor

@g3r4n g3r4n commented Dec 12, 2023

With mysql migrations you can change the migration table name, this PR add support for migration table name change for pg.

For context I'm trying to add dynamic schema support to my application. This can be achieved easily if we can change the migration table. I'm using the database connection to specify, through the search path, the schema to do the migration on but I need to have separate migration table for each schema.

@g3r4n g3r4n force-pushed the g3r4n/feat/pg-migration-table-name-support branch from 7315ac7 to 5233a89 Compare December 12, 2023 21:50
For mysql migrations you can change the migraton table, this commit add support for migration table name change.
@AndriiSherman
Copy link
Member

Thanks for PR!
I think you need to add 1 more pg driver neon-http and and migrator changes there as well.
Also would be great to make drizzle schema customizable same as table name for migrations

@g3r4n
Copy link
Contributor Author

g3r4n commented Dec 13, 2023

@AndriiSherman done !

@AndriiSherman
Copy link
Member

I just thought about one more addition I would like to have in this PR before the actual merge. I think we need to add a few tests for migrations. I will guide you a bit on what and where should be added:

Here is a test example for migrate(). In this test, we run migrations and then try to query the tables that are in the migration script. If no errors occur, it means migrate() worked as expected.

It would be great if you could create another set of tests to check:

  • Custom schema is working.
  • Custom table name is working.
  • Both custom schema and custom table name are working.

You can check it by querying the specific custom table and custom schema to see if those tables are created and not empty. Additionally, you can query tables from the migration script.

It would be great if you could add it for:

@g3r4n
Copy link
Contributor Author

g3r4n commented Dec 19, 2023

@AndriiSherman I've added the tests.
I was unable to run them for vercel/neon because you can't test it using a local docker DB.

@adrienbaron
Copy link

Thanks for your work @g3r4n ! I actually need this now too and was going to do a PR of my own, glad to see someone already picked it up ❤️!

@g3r4n
Copy link
Contributor Author

g3r4n commented Dec 22, 2023

@AndriiSherman anything more you need from my end to merge this PR ?

@AndriiSherman
Copy link
Member

@g3r4n this all looks good! Just resolve the conflicts and I'll merge this PR

@AndriiSherman AndriiSherman changed the base branch from main to beta December 28, 2023 20:17
@g3r4n
Copy link
Contributor Author

g3r4n commented Dec 31, 2023

@AndriiSherman Done !

@adrienbaron
Copy link

adrienbaron commented Feb 1, 2024

@g3r4n it seems like there are new conflicts 🥺, do you have time to resolve them? If not I'm happy to branch of this PR and do it!
@AndriiSherman I'd love to see this merged once conflicts are resolved 🎉!

@AndriiSherman AndriiSherman changed the base branch from beta to main February 29, 2024 07:16
@AndriiSherman
Copy link
Member

I'll resolve the conflicts

@g3r4n
Copy link
Contributor Author

g3r4n commented Feb 29, 2024

@AndriiSherman let me know if you need any help !

@AndriiSherman
Copy link
Member

@AndriiSherman let me know if you need any help !

I think it's done. I just added this feature to SQLite as well. I'm going to merge it today and add it to the 0.29.5 release

@AndriiSherman AndriiSherman merged commit 793d44d into drizzle-team:main Mar 2, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants