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

Where does a TableCreateStatement go? #478

Closed
alper opened this issue Jan 22, 2022 · 3 comments
Closed

Where does a TableCreateStatement go? #478

alper opened this issue Jan 22, 2022 · 3 comments

Comments

@alper
Copy link

alper commented Jan 22, 2022

I want to create a new Model and have that create database tables as well.

I saw this: https://docs.rs/sea-query/0.20.0/sea_query/table/struct.TableCreateStatement.html

But where does it go? Will that automatically create a Model

@alper
Copy link
Author

alper commented Jan 22, 2022

I put it in my main and ran it once just like the Axum example.

@alper alper closed this as completed Jan 22, 2022
@alper
Copy link
Author

alper commented Jan 22, 2022

Here's the line in the example: https://github.com/SeaQL/sea-orm/blob/master/examples/axum_example/src/main.rs#L37

Still not sure whether to run that on every application start or not.

@billy1624
Copy link
Member

Here's the line in the example: https://github.com/SeaQL/sea-orm/blob/master/examples/axum_example/src/main.rs#L37

Still not sure whether to run that on every application start or not.

In this demo, yes, we run the create table statement every time on application startup. As I said in another discussion, once we have migration (#335) in place. You could migrate the database once by hand via the migrator CLI. But I would say running the migration automatically on application startup would be better, this ensure you application is running against a database with up-to-date schema.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants