12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 |
- use sea_orm_migration::prelude::*;
- use crate::db_enums::*;
- #[derive(DeriveMigrationName)]
- pub struct Migration;
- #[async_trait::async_trait]
- impl MigrationTrait for Migration {
- async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
- manager
- .create_table(
- Table::create()
- .table(UserTokens::Table)
- .if_not_exists()
- .col(
- ColumnDef::new(UserTokens::Id)
- .integer()
- .not_null()
- .auto_increment()
- .primary_key(),
- )
- .col(ColumnDef::new(UserTokens::Token).text().not_null().unique_key())
- .col(ColumnDef::new(UserTokens::ChatId).big_integer().unique_key())
- .col(ColumnDef::new(UserTokens::Descr).text().not_null())
- .to_owned(),
- )
- .await?;
- manager
- .create_table(
- Table::create()
- .table(Locations::Table)
- .if_not_exists()
- .col(
- ColumnDef::new(Locations::Id)
- .integer()
- .not_null()
- .auto_increment()
- .primary_key(),
- )
- .col(ColumnDef::new(Locations::Endpoint).text().not_null())
- .col(ColumnDef::new(Locations::Descr).text().not_null())
- .to_owned(),
- )
- .await
- }
- async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
- // Replace the sample below with your own migration scripts
- manager
- .drop_table(Table::drop().table(UserTokens::Table).to_owned())
- .await?;
- manager
- .drop_table(Table::drop().table(Locations::Table).to_owned())
- .await
- }
- }
|