mirror of
https://github.com/orangecoding/fredy.git
synced 2026-06-16 12:31:07 +00:00
* adding new feature: watch listings for changes * adding todo for watch feature * sort by watch
16 lines
530 B
JavaScript
16 lines
530 B
JavaScript
// Migration: Adding a new table to store if somebody "watches" (a.k.a favorite) a listing
|
|
|
|
export function up(db) {
|
|
db.exec(`
|
|
CREATE TABLE IF NOT EXISTS watch_list
|
|
(
|
|
id TEXT PRIMARY KEY,
|
|
listing_id TEXT NOT NULL,
|
|
user_id TEXT NOT NULL,
|
|
FOREIGN KEY (listing_id) REFERENCES listings (id) ON DELETE CASCADE,
|
|
FOREIGN KEY (user_id) REFERENCES users (id) ON DELETE CASCADE
|
|
);
|
|
CREATE UNIQUE INDEX IF NOT EXISTS idx_watch_list ON watch_list (listing_id, user_id);
|
|
`);
|
|
}
|