2024-03-22 05:34:08 +01:00
|
|
|
use sea_orm_migration::prelude::*;
|
|
|
|
|
|
|
|
#[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(Likes::Table)
|
|
|
|
.col(
|
|
|
|
ColumnDef::new(Likes::Id)
|
|
|
|
.integer()
|
|
|
|
.auto_increment()
|
|
|
|
.not_null()
|
|
|
|
.primary_key()
|
|
|
|
)
|
|
|
|
.col(ColumnDef::new(Likes::Actor).string().not_null())
|
|
|
|
.col(ColumnDef::new(Likes::Likes).string().not_null())
|
2024-03-23 04:40:39 +01:00
|
|
|
.col(ColumnDef::new(Likes::Date).date_time().not_null())
|
2024-03-22 05:34:08 +01:00
|
|
|
.to_owned()
|
|
|
|
)
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
manager
|
|
|
|
.create_table(
|
|
|
|
Table::create()
|
|
|
|
.table(Shares::Table)
|
|
|
|
.col(
|
|
|
|
ColumnDef::new(Shares::Id)
|
|
|
|
.integer()
|
|
|
|
.auto_increment()
|
|
|
|
.not_null()
|
|
|
|
.primary_key()
|
|
|
|
)
|
|
|
|
.col(ColumnDef::new(Shares::Actor).string().not_null())
|
|
|
|
.col(ColumnDef::new(Shares::Shares).string().not_null())
|
|
|
|
.col(ColumnDef::new(Shares::Date).date_time().not_null())
|
|
|
|
.to_owned()
|
|
|
|
)
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
|
|
|
manager
|
|
|
|
.drop_table(Table::drop().table(Likes::Table).to_owned())
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
manager
|
|
|
|
.drop_table(Table::drop().table(Shares::Table).to_owned())
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(DeriveIden)]
|
|
|
|
enum Likes {
|
|
|
|
Table,
|
|
|
|
Id,
|
|
|
|
Actor,
|
|
|
|
Likes,
|
2024-03-23 04:40:39 +01:00
|
|
|
Date,
|
2024-03-22 05:34:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(DeriveIden)]
|
|
|
|
enum Shares {
|
|
|
|
Table,
|
|
|
|
Id,
|
|
|
|
Actor,
|
|
|
|
Shares,
|
|
|
|
Date,
|
|
|
|
}
|