-
-
Notifications
You must be signed in to change notification settings - Fork 664
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
[FEATURE]: Allow to specify a particular schema name in the migrate() config for postgres #908
Comments
I have modified the code and tested in my dev environment. It works satisfactorily. I am reproducing the full patched file "./drizzle-orm/src/migrator.ts" below for your reference and inclusion. The file is annotated with two types of in-line comments:
|
@aflatoon2874 Here is my angle on this matter -> #1638
I think your solution is the real deal but that needs to be implemented for all the dialect |
@kennyjwilli Yes because the state of the migration is saved at the same place for all schemas which isn't what you want with multi schema migration. All migration are "schemaless" so by just changing the connection string you can migrate the schema you want |
I noticed that your changes were merged in terms of the table and schemaName for the migration tracking, perhaps it would be better to just add a schemaId column to the table instead of having a different table/schema for each migrated schema? Nonetheless, it looks like the URL I am in exactly the same position currently, requiring identical migrations per schema and initial db setup for new users on their own schema and have not found any elegant solution. |
@bitaccesscomau I'm specifying the search_path in the connection url. |
Describe what you want
Allow users to specify a target schema name for running migrations in postgres. Currently the
migrate()
intrinsically always targetpublic
schema. This enhancement will enable us to do migrations in multi-tenant use cases where each schema must have the same migrations applied to be in sync with the application requirements. Please take a look at the following code that is written as per the current functionality supported.I propose to extend the migrate config to have additional property of
schema
orschemas
to specify a single target schema or an array of schema names. In the multiple schema names scenario themigrate()
function can iterate on the array and apply the migrations one by one on each schema.The following code snippets show the proposed enhancements.
public
schemaThe text was updated successfully, but these errors were encountered: