Skip to content

Commit

Permalink
Add some constraint to db, and fix list test
Browse files Browse the repository at this point in the history
and refactor other tests to use begin_transaction
  • Loading branch information
trinity-1686a committed Apr 17, 2019
1 parent 701ec1f commit 2086ce7
Show file tree
Hide file tree
Showing 10 changed files with 638 additions and 688 deletions.
6 changes: 4 additions & 2 deletions migrations/postgres/2019-04-11-145757_timeline/up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ CREATE TABLE timeline_definition(
id SERIAL PRIMARY KEY,
user_id integer REFERENCES users ON DELETE CASCADE,
name VARCHAR NOT NULL,
query VARCHAR NOT NULL
query VARCHAR NOT NULL,
CONSTRAINT timeline_unique_user_name UNIQUE(user_id, name)
);

CREATE TABLE timeline(
Expand All @@ -17,7 +18,8 @@ CREATE TABLE lists(
id SERIAL PRIMARY KEY,
name VARCHAR NOT NULL,
user_id integer REFERENCES users ON DELETE CASCADE,
type integer NOT NULL
type integer NOT NULL,
CONSTRAINT list_unique_user_name UNIQUE(user_id, name)
);

CREATE TABLE list_elems(
Expand Down
6 changes: 4 additions & 2 deletions migrations/sqlite/2019-04-11-145757_timeline/up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ CREATE TABLE timeline_definition(
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
user_id INTEGER REFERENCES users(id) ON DELETE CASCADE,
name VARCHAR NOT NULL,
query VARCHAR NOT NULL
query VARCHAR NOT NULL,
CONSTRAINT timeline_unique_user_name UNIQUE(user_id, name)
);

CREATE TABLE timeline(
Expand All @@ -17,7 +18,8 @@ CREATE TABLE lists(
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
name VARCHAR NOT NULL,
user_id integer REFERENCES users(id) ON DELETE CASCADE,
type integer NOT NULL
type integer NOT NULL,
CONSTRAINT timeline_unique_user_name UNIQUE(user_id, name)
);

CREATE TABLE list_elems(
Expand Down
Loading

0 comments on commit 2086ce7

Please sign in to comment.