From d934a700f7d69de025e8ee7112548dbae36fdb71 Mon Sep 17 00:00:00 2001 From: JMARyA Date: Sun, 8 Dec 2024 19:16:45 +0100 Subject: [PATCH] fix migrations --- migrations_postgres/0001_init.sql | 14 ++++++++++++++ {migrations => migrations_sqlite}/0001_init.sql | 0 src/db.rs | 4 ++-- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 migrations_postgres/0001_init.sql rename {migrations => migrations_sqlite}/0001_init.sql (100%) diff --git a/migrations_postgres/0001_init.sql b/migrations_postgres/0001_init.sql new file mode 100644 index 0000000..95ddc5f --- /dev/null +++ b/migrations_postgres/0001_init.sql @@ -0,0 +1,14 @@ +CREATE TABLE IF NOT EXISTS urls ( + id SERIAL PRIMARY KEY, + url TEXT NOT NULL, + timestamp TEXT NOT NULL +); + +CREATE TABLE IF NOT EXISTS item_log ( + id SERIAL PRIMARY KEY, + module TEXT NOT NULL, + name TEXT NOT NULL, + url TEXT NOT NULL, + timestamp TEXT NOT NULL, + CONSTRAINT unique_module_name_url UNIQUE (module, name, url) +); diff --git a/migrations/0001_init.sql b/migrations_sqlite/0001_init.sql similarity index 100% rename from migrations/0001_init.sql rename to migrations_sqlite/0001_init.sql diff --git a/src/db.rs b/src/db.rs index 19695b4..0e9bfb4 100644 --- a/src/db.rs +++ b/src/db.rs @@ -29,14 +29,14 @@ impl DatabaseBackend { .await .unwrap(), ); - sqlx::migrate!("./migrations") + sqlx::migrate!("./migrations_postgres") .run(postgres.as_ref().unwrap()) .await .unwrap(); } else { ensure_file_exists(db_url); sqlite = Some(sqlx::sqlite::SqlitePool::connect(db_url).await.unwrap()); - sqlx::migrate!("./migrations") + sqlx::migrate!("./migrations_sqlite") .run(sqlite.as_ref().unwrap()) .await .unwrap();