wb_cache/test/simulation/db/migrations/
product.rs

1use sea_orm_migration::prelude::*;
2
3pub struct Migration;
4
5impl MigrationName for Migration {
6    fn name(&self) -> &str {
7        "product_migration"
8    }
9}
10
11#[async_trait::async_trait]
12impl MigrationTrait for Migration {
13    async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
14        // Create Product table migration logic here.
15        manager
16            .create_table(
17                Table::create()
18                    .table(Products::Table)
19                    .if_not_exists()
20                    .col(ColumnDef::new(Products::Id).integer().not_null().primary_key())
21                    .col(ColumnDef::new(Products::Name).string().not_null())
22                    .col(ColumnDef::new(Products::Price).double().not_null())
23                    .col(ColumnDef::new(Products::Views).big_integer().not_null())
24                    .to_owned(),
25            )
26            .await
27    }
28
29    async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
30        // Drop Product table migration logic here.
31        manager
32            .drop_table(Table::drop().table(Products::Table).to_owned())
33            .await
34    }
35}
36
37#[derive(Iden)]
38pub enum Products {
39    Table,
40    Id,
41    Name,
42    Price,
43    Views,
44}