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

Allow for creation of indexes for PostgreSQL and SQLite #593

Merged
merged 3 commits into from
Mar 20, 2022

Conversation

nickb937
Copy link
Contributor

PostgreSQL and SQLite do not allow creation of general indexes within a CREATE TABLE statement, so a method is required to generate CREATE INDEX statements for these.

create_table_from_entity avoids creating invalid statements for non-MySQL backends,
forcing uses to explicitly run create_index_from_entity. Ideally creating indexes would be removed from create_table_from_entity entirely, but this would introduce a breaking change for MySQL use.

PR Info

PostgreSQL and SQLite do not allow creation of general indexes within a `CREATE TABLE` statement, so a method is required to generate `CREATE INDEX` statements for these.

`create_table_from_entity` avoids creating invalid statements for non-MySQL backends,
forcing uses to explicitly run `create_index_from_entity`.  Ideally creating indexes would be removed from `create_table_from_entity` entirely, but this would introduce a breaking change for MySQL use.
@tyt2y3
Copy link
Member

tyt2y3 commented Mar 15, 2022

Ideally creating indexes would be removed from create_table_from_entity entirely, but this would introduce a breaking change for MySQL use.

I agree with this change. just remove create index from create_table_from_entity entirely is fine

src/tests_cfg/cake_filling_price.rs Outdated Show resolved Hide resolved
@tyt2y3
Copy link
Member

tyt2y3 commented Mar 15, 2022

Thank you for the contribution all-in-all

Use `create_index_from_entity` for all index creation for consistency across all backends.  This is a backwards incompatible change, affecting those using MySQL backend when creating the schema only.
@tyt2y3 tyt2y3 merged commit a09790e into SeaQL:master Mar 20, 2022
billy1624 added a commit to SeaQL/seaql.github.io that referenced this pull request Mar 25, 2022
@tyt2y3 tyt2y3 changed the title Allow for creation of indexes for PostgeSQL and SQLite Allow for creation of indexes for PostgreSQL and SQLite Mar 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

#[sea_orm(indexed)] only works for MySQL
2 participants