GRA0007 / crab.fit

Enter your availability to find a time that works for everyone!
https://crab.fit
GNU General Public License v3.0
244 stars 31 forks source link

API SQLite Adaptor: "Sqlite does not support modification of foreign key constraints to existing tables" #296

Open cubuzz opened 1 year ago

cubuzz commented 1 year ago

Description of the bug

When setting up a new installation, the following error gets thrown.

CREATE TABLE IF NOT EXISTS "person" (
  "name" text NOT NULL,
  "password_hash" text,
  "created_at" text NOT NULL,
  "availability" text NOT NULL,
  "event_id" text NOT NULL,
  PRIMARY KEY ("event_id", "name")
)

thread 'main' panicked at 'Sqlite does not support modification of foreign key constraints to existing tables', /usr/local/cargo/registry/src/index.crates.io-6f17d22bba15001f/sea-query-0.28.4/src/backend/sqlite/foreign_key.rs:34:13
stack backtrace:
   0: rust_begin_unwind
             at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/std/src/panicking.rs:593:5
   1: core::panicking::panic_fmt
             at /rustc/8ede3aae28fe6e4d52b38157d7bfe0d3bceef225/library/core/src/panicking.rs:67:14
   2: sea_query::backend::sqlite::foreign_key::<impl sea_query::backend::foreign_key_builder::ForeignKeyBuilder for sea_query::backend::sqlite::SqliteQueryBuilder>::prepare_foreign_key_create_statement_internal
   3: <sea_query::foreign_key::create::ForeignKeyCreateStatement as sea_orm::database::statement::StatementBuilder>::build
   4: <sql_adaptor::migration::m01_setup_tables::Migration as sea_orm_migration::MigrationTrait>::up::{{closure}}
   5: sea_orm_migration::migrator::MigratorTrait::up::{{closure}}::{{closure}}::{{closure}}
   6: sea_orm_migration::migrator::MigratorTrait::up::{{closure}}
   7: tokio::runtime::context::BlockingRegionGuard::block_on
   8: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
   9: tokio::runtime::runtime::Runtime::block_on
  10: crabfit_api::main

To reproduce

Compile the API using the sql-adaptor Touch a new database file Attempt to connect using SQLite to said database file

Expected behavior

Migrations pass and the API starts

Additional information

No response