This commit is contained in:
parent
899ce99bff
commit
d934a700f7
3 changed files with 16 additions and 2 deletions
14
migrations_postgres/0001_init.sql
Normal file
14
migrations_postgres/0001_init.sql
Normal file
|
@ -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)
|
||||||
|
);
|
|
@ -29,14 +29,14 @@ impl DatabaseBackend {
|
||||||
.await
|
.await
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
);
|
);
|
||||||
sqlx::migrate!("./migrations")
|
sqlx::migrate!("./migrations_postgres")
|
||||||
.run(postgres.as_ref().unwrap())
|
.run(postgres.as_ref().unwrap())
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
} else {
|
} else {
|
||||||
ensure_file_exists(db_url);
|
ensure_file_exists(db_url);
|
||||||
sqlite = Some(sqlx::sqlite::SqlitePool::connect(db_url).await.unwrap());
|
sqlite = Some(sqlx::sqlite::SqlitePool::connect(db_url).await.unwrap());
|
||||||
sqlx::migrate!("./migrations")
|
sqlx::migrate!("./migrations_sqlite")
|
||||||
.run(sqlite.as_ref().unwrap())
|
.run(sqlite.as_ref().unwrap())
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
Loading…
Reference in a new issue