diff --git a/server/migration/src/lib.rs b/server/migration/src/lib.rs index af739585..c8765d55 100644 --- a/server/migration/src/lib.rs +++ b/server/migration/src/lib.rs @@ -7,6 +7,7 @@ mod m20230614_083950_crate_form_response_period_table; mod m20230622_053919_create_form_webhook; mod m20230811_062425_create_answer_tables; mod m20230908_140907_create_default_answer_titles; +mod m20231008_135425_create_user_table; pub struct Migrator; @@ -21,6 +22,7 @@ impl MigratorTrait for Migrator { Box::new(m20230622_053919_create_form_webhook::Migration), Box::new(m20230811_062425_create_answer_tables::Migration), Box::new(m20230908_140907_create_default_answer_titles::Migration), + Box::new(m20231008_135425_create_user_table::Migration), ] } } diff --git a/server/migration/src/m20231008_135425_create_user_table.rs b/server/migration/src/m20231008_135425_create_user_table.rs new file mode 100644 index 00000000..9152a95c --- /dev/null +++ b/server/migration/src/m20231008_135425_create_user_table.rs @@ -0,0 +1,41 @@ +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(UsersTable::Users) + .if_not_exists() + .col( + ColumnDef::new(UsersTable::Id) + .uuid() + .not_null() + .auto_increment() + .primary_key(), + ) + .col(ColumnDef::new(UsersTable::Uuid).uuid().not_null()) + .col(ColumnDef::new(UsersTable::Name).string().not_null()) + .to_owned(), + ) + .await + } + + async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> { + manager + .drop_table(Table::drop().table(UsersTable::Users).to_owned()) + .await + } +} + +#[derive(DeriveIden)] +enum UsersTable { + Users, + Id, + Uuid, + Name, +}