A card game engine for TCGs, primarily Magic: The Gathering but with support for others
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Adding migrations as well as a script to generate them

+62 -28
+5
create_migration.sh
··· 1 + #!/bin/bash 2 + 3 + cd migration/src 4 + DATABASE_URL=sqlite://../../cards.db cargo run -p migration -- generate $1 5 + cd ../..
+7 -3
migration/src/lib.rs
··· 1 1 pub use sea_orm_migration::prelude::*; 2 2 3 - mod m20260420_000001_create_card_table; 4 - 5 3 pub struct Migrator; 6 4 7 5 #[async_trait::async_trait] 8 6 impl MigratorTrait for Migrator { 9 7 fn migrations() -> Vec<Box<dyn MigrationTrait>> { 10 - vec![Box::new(m20260420_000001_create_card_table::Migration)] 8 + vec![ 9 + Box::new(m20260421_001329_add_card_table::Migration), 10 + Box::new(m20260421_001539_add_first_test_card::Migration), 11 + ] 11 12 } 12 13 } 14 + 15 + mod m20260421_001329_add_card_table; 16 + mod m20260421_001539_add_first_test_card;
-25
migration/src/m20260420_000001_create_card_table.rs
··· 1 - use sea_orm_migration::{prelude::*, schema::*}; 2 - 3 - #[derive(DeriveMigrationName)] 4 - pub struct Migration; 5 - 6 - #[async_trait::async_trait] 7 - impl MigrationTrait for Migration { 8 - async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { 9 - manager 10 - .create_table( 11 - Table::create() 12 - .table("card") 13 - .if_not_exists() 14 - .col(pk_auto("id")) 15 - .col(string("name")) 16 - .col(string("text")) 17 - .to_owned() 18 - ) 19 - .await 20 - } 21 - 22 - async fn down(&self, _manager: &SchemaManager) -> Result<(), DbErr> { 23 - todo!(); 24 - } 25 - }
+35
migration/src/m20260421_001329_add_card_table.rs
··· 1 + use sea_orm_migration::prelude::*; 2 + 3 + #[derive(DeriveMigrationName)] 4 + pub struct Migration; 5 + 6 + #[async_trait::async_trait] 7 + impl MigrationTrait for Migration { 8 + async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { 9 + manager 10 + .create_table( 11 + Table::create() 12 + .table("card") 13 + .if_not_exists() 14 + .col(ColumnDef::new("id").integer().not_null().auto_increment().primary_key()) 15 + .col(ColumnDef::new("name").string().not_null()) 16 + .col(ColumnDef::new("text").string()) 17 + .col(ColumnDef::new("type").enumeration("CardType", vec!["creature"])) 18 + .col(ColumnDef::new("power").integer()) 19 + .col(ColumnDef::new("toughness").integer()) 20 + .to_owned() 21 + ) 22 + .await 23 + } 24 + 25 + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { 26 + manager 27 + .drop_table( 28 + Table::drop() 29 + .table("card") 30 + .if_exists() 31 + .to_owned() 32 + ) 33 + .await 34 + } 35 + }
+15
migration/src/m20260421_001539_add_first_test_card.rs
··· 1 + use sea_orm_migration::prelude::*; 2 + 3 + #[derive(DeriveMigrationName)] 4 + pub struct Migration; 5 + 6 + #[async_trait::async_trait] 7 + impl MigrationTrait for Migration { 8 + async fn up(&self, _manager: &SchemaManager) -> Result<(), DbErr> { 9 + todo!(); 10 + } 11 + 12 + async fn down(&self, _manager: &SchemaManager) -> Result<(), DbErr> { 13 + todo!(); 14 + } 15 + }