From 36eb96416d4df869069c94e7039cccaacf4f59c5 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Fri, 17 May 2024 22:05:40 -0500 Subject: [PATCH] No ORM because I'm not really sure I gain much --- migration/Cargo.toml | 22 --------- migration/README.md | 41 ---------------- migration/src/lib.rs | 12 ----- .../src/m20220101_000001_create_table.rs | 47 ------------------- migration/src/main.rs | 6 --- 5 files changed, 128 deletions(-) delete mode 100644 migration/Cargo.toml delete mode 100644 migration/README.md delete mode 100644 migration/src/lib.rs delete mode 100644 migration/src/m20220101_000001_create_table.rs delete mode 100644 migration/src/main.rs diff --git a/migration/Cargo.toml b/migration/Cargo.toml deleted file mode 100644 index e4f8ca2..0000000 --- a/migration/Cargo.toml +++ /dev/null @@ -1,22 +0,0 @@ -[package] -name = "migration" -version = "0.1.0" -edition = "2021" -publish = false - -[lib] -name = "migration" -path = "src/lib.rs" - -[dependencies] -async-std = { version = "1", features = ["attributes", "tokio1"] } - -[dependencies.sea-orm-migration] -version = "0.12.0" -features = [ - # Enable at least one `ASYNC_RUNTIME` and `DATABASE_DRIVER` feature if you want to run migration via CLI. - # View the list of supported features at https://www.sea-ql.org/SeaORM/docs/install-and-config/database-and-async-runtime. - # e.g. - "runtime-tokio-rustls", # `ASYNC_RUNTIME` feature - "sqlx-postgres", # `DATABASE_DRIVER` feature -] diff --git a/migration/README.md b/migration/README.md deleted file mode 100644 index 3b438d8..0000000 --- a/migration/README.md +++ /dev/null @@ -1,41 +0,0 @@ -# Running Migrator CLI - -- Generate a new migration file - ```sh - cargo run -- generate MIGRATION_NAME - ``` -- Apply all pending migrations - ```sh - cargo run - ``` - ```sh - cargo run -- up - ``` -- Apply first 10 pending migrations - ```sh - cargo run -- up -n 10 - ``` -- Rollback last applied migrations - ```sh - cargo run -- down - ``` -- Rollback last 10 applied migrations - ```sh - cargo run -- down -n 10 - ``` -- Drop all tables from the database, then reapply all migrations - ```sh - cargo run -- fresh - ``` -- Rollback all applied migrations, then reapply all migrations - ```sh - cargo run -- refresh - ``` -- Rollback all applied migrations - ```sh - cargo run -- reset - ``` -- Check the status of all migrations - ```sh - cargo run -- status - ``` diff --git a/migration/src/lib.rs b/migration/src/lib.rs deleted file mode 100644 index 2c605af..0000000 --- a/migration/src/lib.rs +++ /dev/null @@ -1,12 +0,0 @@ -pub use sea_orm_migration::prelude::*; - -mod m20220101_000001_create_table; - -pub struct Migrator; - -#[async_trait::async_trait] -impl MigratorTrait for Migrator { - fn migrations() -> Vec> { - vec![Box::new(m20220101_000001_create_table::Migration)] - } -} diff --git a/migration/src/m20220101_000001_create_table.rs b/migration/src/m20220101_000001_create_table.rs deleted file mode 100644 index c8f2a5d..0000000 --- a/migration/src/m20220101_000001_create_table.rs +++ /dev/null @@ -1,47 +0,0 @@ -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> { - // Replace the sample below with your own migration scripts - todo!(); - - manager - .create_table( - Table::create() - .table(Post::Table) - .if_not_exists() - .col( - ColumnDef::new(Post::Id) - .integer() - .not_null() - .auto_increment() - .primary_key(), - ) - .col(ColumnDef::new(Post::Title).string().not_null()) - .col(ColumnDef::new(Post::Text).string().not_null()) - .to_owned(), - ) - .await - } - - async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { - // Replace the sample below with your own migration scripts - todo!(); - - manager - .drop_table(Table::drop().table(Post::Table).to_owned()) - .await - } -} - -#[derive(DeriveIden)] -enum Post { - Table, - Id, - Title, - Text, -} diff --git a/migration/src/main.rs b/migration/src/main.rs deleted file mode 100644 index c6b6e48..0000000 --- a/migration/src/main.rs +++ /dev/null @@ -1,6 +0,0 @@ -use sea_orm_migration::prelude::*; - -#[async_std::main] -async fn main() { - cli::run_cli(migration::Migrator).await; -}