-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: simonsan <[email protected]>
- Loading branch information
Showing
10 changed files
with
102 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,4 @@ logs/* | |
.cargo/config.toml | ||
|
||
# Database | ||
data/pace.sqlite3 | ||
db/activities.pace.sqlite3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- migrate:up | ||
CREATE TABLE activity_kinds ( | ||
guid TEXT PRIMARY KEY, | ||
kind TEXT NOT NULL | ||
); | ||
|
||
-- migrate:down | ||
DROP TABLE activity_kinds; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- migrate:up | ||
CREATE TABLE tags ( | ||
guid TEXT PRIMARY KEY, | ||
tag TEXT NOT NULL | ||
); | ||
|
||
-- migrate:down | ||
DROP TABLE tags; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-- migrate:up | ||
CREATE TABLE activities_tags ( | ||
guid TEXT PRIMARY KEY, | ||
tag_guid TEXT NOT NULL, | ||
activity_guid TEXT NOT NULL, | ||
FOREIGN KEY (tag_guid) REFERENCES tags(guid), | ||
FOREIGN KEY (activity_guid) REFERENCES activities(guid) | ||
); | ||
|
||
-- migrate:down | ||
DROP TABLE activities_tags; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
-- migrate:up | ||
CREATE TABLE activity_status ( | ||
guid TEXT PRIMARY KEY, | ||
status TEXT NOT NULL | ||
); | ||
|
||
-- migrate:down | ||
DROP TABLE activity_status; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
-- migrate:up | ||
CREATE TABLE categories ( | ||
guid TEXT PRIMARY KEY, | ||
category TEXT NOT NULL, | ||
description TEXT NULL | ||
); | ||
|
||
-- migrate:down | ||
DROP TABLE categories; |
11 changes: 11 additions & 0 deletions
11
db/migrations/20240326130013_create_activities_categories.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
-- migrate:up | ||
CREATE TABLE activities_categories ( | ||
guid TEXT PRIMARY KEY, | ||
category_guid TEXT NOT NULL, | ||
activity_guid TEXT NOT NULL, | ||
FOREIGN KEY (category_guid) REFERENCES categories(guid), | ||
FOREIGN KEY (activity_guid) REFERENCES activities(guid) | ||
); | ||
|
||
-- migrate:down | ||
DROP TABLE activities_categories; |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,55 @@ | ||
CREATE TABLE IF NOT EXISTS "schema_migrations" (version varchar(128) primary key); | ||
CREATE TABLE activities ( | ||
id TEXT PRIMARY KEY, | ||
guid TEXT PRIMARY KEY, | ||
category TEXT NOT NULL, | ||
description TEXT NOT NULL, | ||
begin TEXT NOT NULL, | ||
end TEXT NULL, | ||
duration INTEGER NULL, | ||
kind TEXT NOT NULL, | ||
status TEXT NOT NULL, | ||
parent_id TEXT NULL, | ||
FOREIGN KEY (parent_id) REFERENCES activities(id) | ||
parent_guid TEXT NULL, | ||
FOREIGN KEY (kind) REFERENCES activity_kinds(guid), | ||
FOREIGN KEY (status) REFERENCES activity_status(guid), | ||
FOREIGN KEY (parent_guid) REFERENCES activities(guid) | ||
); | ||
CREATE TABLE activity_kinds ( | ||
guid TEXT PRIMARY KEY, | ||
kind TEXT NOT NULL | ||
); | ||
CREATE TABLE tags ( | ||
guid TEXT PRIMARY KEY, | ||
tag TEXT NOT NULL | ||
); | ||
CREATE TABLE activities_tags ( | ||
guid TEXT PRIMARY KEY, | ||
tag_guid TEXT NOT NULL, | ||
activity_guid TEXT NOT NULL, | ||
FOREIGN KEY (tag_guid) REFERENCES tags(guid), | ||
FOREIGN KEY (activity_guid) REFERENCES activities(guid) | ||
); | ||
CREATE TABLE activity_status ( | ||
guid TEXT PRIMARY KEY, | ||
status TEXT NOT NULL | ||
); | ||
CREATE TABLE categories ( | ||
guid TEXT PRIMARY KEY, | ||
category TEXT NOT NULL, | ||
description TEXT NULL | ||
); | ||
CREATE TABLE activities_categories ( | ||
guid TEXT PRIMARY KEY, | ||
category_guid TEXT NOT NULL, | ||
activity_guid TEXT NOT NULL, | ||
FOREIGN KEY (category_guid) REFERENCES categories(guid), | ||
FOREIGN KEY (activity_guid) REFERENCES activities(guid) | ||
); | ||
-- Dbmate schema migrations | ||
INSERT INTO "schema_migrations" (version) VALUES | ||
('20240325143710'); | ||
('20240325143710'), | ||
('20240326124253'), | ||
('20240326125555'), | ||
('20240326125630'), | ||
('20240326125819'), | ||
('20240326125937'), | ||
('20240326130013'); |