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();