Skip to content

Entity-independent migrations #64

Answered by kpot
kpot asked this question in Q&A
Discussion options

You must be logged in to vote

After some digging inside the SeaSchema`s code I found a solution that does the job, although it's a bit verbose. I wonder if something like this should be added to the docs.

Table::create()
    .table(TableRef::Table(Alias::new("my_table_name").into_iden()))
    .if_not_exists()
    .col(
        ColumnDef::new(Alias::new("id"))
            .integer()
            .not_null()
            .auto_increment()
            .primary_key(),
    )
    .col(ColumnDef::new(Alias::new("title")).string().not_null())
    ...

The TableRef enum also offers a variety of other options to specify the table.

Respect to all authors for a great project! You're totally going in the right direction.

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by kpot
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants