-
-
Notifications
You must be signed in to change notification settings - Fork 524
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
sea-orm-cli migrate doesn't respect DATABASE_SCHEMA in .env file #521
Comments
Hey @MattGson, PostgreSQL's migration currently only operate on |
um... this seems like an easy fix? would appreciate PR on this |
@tyt2y3 I would like to work on this issue. After some research, I identified that |
Hey @smonv, thanks for the interest! Note that the migrator is subject to change, see SeaQL/sea-schema#59. Anyways, the schema name (value of |
@billy1624 Thank for guiding me. I'll follow your PR and change the migrator patch if necessary. |
Thanks!! @smonv Feel free to ping us if you need helps :) |
Hey @smonv, @nahuakang would like to take on this issue. Is that fine? |
yes, i'm good with it. |
@smonv Thank you :) I'll claim this! |
@billy1624 Some updates after digging today:
However, So does this mean we should take care of getting the environment value for Questions:
|
Hey @nahuakang, sorry for the delay. Thanks for the investigations!
Correct, and
Take this as reference, which inject schema name for SeaORM entity sea-orm/src/entity/base_entity.rs Lines 31 to 37 in 3f90c09
However, for migration, we're injecting schema name into existing SeaQuery statement. Which will be performed inside methods inside sea-orm/sea-orm-migration/src/manager.rs Lines 37 to 133 in 3f90c09
E.g. Converting the
Let me know if it was unclear. |
I'm guessing that the The issue is that a lot of the other // table reference is Option<DynIden>
pub struct IndexCreateStatement {
pub(crate) table: Option<DynIden>,
pub(crate) index: TableIndex,
pub(crate) primary: bool,
pub(crate) unique: bool,
pub(crate) index_type: Option<IndexType>,
}
// No table reference
pub struct TypeCreateStatement {
pub(crate) name: Option<DynIden>,
pub(crate) as_type: Option<TypeAs>,
pub(crate) values: Vec<DynIden>,
}
// This is a field in `ForeignKeyCreateStatement`
pub struct TableForeignKey {
pub(crate) name: Option<String>,
pub(crate) table: Option<DynIden>,
pub(crate) ref_table: Option<DynIden>,
pub(crate) columns: Vec<DynIden>,
pub(crate) ref_columns: Vec<DynIden>,
pub(crate) on_delete: Option<ForeignKeyAction>,
pub(crate) on_update: Option<ForeignKeyAction>,
} Let me know what we should do (if we should create new issues and solve another issue first) before we address this one? :) |
Good point! I think we need to update these statement to quantify the schema name For PostgreSQL type statement, it actually supports schema name. But we didn't implement it in SeaQuery |
So what should the next step be in terms of moving forward with this issue? Should we have a separate PR that addresses |
Yes, please open an issue & PR on SeaQuery. Check all
|
With this PR on the way, I can resume this issue :) |
Hey @nahuakang, I have a plan: On
The db schema will be passed to On We have a new
Implements And we need a new struct, let say Then, we modify the behaviour of public API of
|
Thanks! I've read it and will start on it (might take a bit of time :)). |
Description
Running the command:
Always runs migrations against the
public
schema in PostgreSQL rather than the schema specified in.env
Steps to Reproduce
.env
file withDATABASE_SCHEMA=not_public
sea-orm-cli migrate...
Expected Behavior
Migrations are run in specified schema
Actual Behavior
See that all migrations were run in
public
schemaVersions
The text was updated successfully, but these errors were encountered: