From ab0e7007c593bad246b09e4253037293f0c9bcd1 Mon Sep 17 00:00:00 2001 From: alemi Date: Fri, 24 May 2024 03:53:03 +0200 Subject: [PATCH] fix: oops must first create instances --- ...001_create_actor_activity_object_tables.rs | 62 +++++++++---------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/src/migrations/m20240524_000001_create_actor_activity_object_tables.rs b/src/migrations/m20240524_000001_create_actor_activity_object_tables.rs index e0ffd7a8..e2b9b999 100644 --- a/src/migrations/m20240524_000001_create_actor_activity_object_tables.rs +++ b/src/migrations/m20240524_000001_create_actor_activity_object_tables.rs @@ -89,6 +89,37 @@ pub struct Migration; impl MigrationTrait for Migration { async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> { + manager + .create_table( + Table::create() + .table(Instances::Table) + .comment("known other instances in the fediverse") + .col( + ColumnDef::new(Instances::Id) + .integer() + .not_null() + .auto_increment() + .primary_key() + ) + .col(ColumnDef::new(Instances::Name).string().null()) + .col(ColumnDef::new(Instances::Domain).string().not_null()) + .col(ColumnDef::new(Instances::Software).string().null()) + .col(ColumnDef::new(Instances::Version).string().null()) + .col(ColumnDef::new(Instances::DownSince).date_time().null()) + .col(ColumnDef::new(Instances::Users).integer().null()) + .col(ColumnDef::new(Instances::Posts).integer().null()) + .col(ColumnDef::new(Instances::Published).date_time().not_null().default(Expr::current_timestamp())) + .col(ColumnDef::new(Instances::Updated).date_time().not_null().default(Expr::current_timestamp())) + .to_owned() + ) + .await?; + + manager + .create_index(Index::create().name("index-instances-domain").table(Instances::Table).col(Instances::Domain).to_owned()) + .await?; + + + manager .create_table( Table::create() @@ -264,37 +295,6 @@ impl MigrationTrait for Migration { .create_index(Index::create().name("index-objects-context").table(Objects::Table).col(Objects::Context).to_owned()) .await?; - - - manager - .create_table( - Table::create() - .table(Instances::Table) - .comment("known other instances in the fediverse") - .col( - ColumnDef::new(Instances::Id) - .integer() - .not_null() - .auto_increment() - .primary_key() - ) - .col(ColumnDef::new(Instances::Name).string().null()) - .col(ColumnDef::new(Instances::Domain).string().not_null()) - .col(ColumnDef::new(Instances::Software).string().null()) - .col(ColumnDef::new(Instances::Version).string().null()) - .col(ColumnDef::new(Instances::DownSince).date_time().null()) - .col(ColumnDef::new(Instances::Users).integer().null()) - .col(ColumnDef::new(Instances::Posts).integer().null()) - .col(ColumnDef::new(Instances::Published).date_time().not_null().default(Expr::current_timestamp())) - .col(ColumnDef::new(Instances::Updated).date_time().not_null().default(Expr::current_timestamp())) - .to_owned() - ) - .await?; - - manager - .create_index(Index::create().name("index-instances-domain").table(Instances::Table).col(Instances::Domain).to_owned()) - .await?; - Ok(()) }