Skip to content

Commit

Permalink
Db change (#94)
Browse files Browse the repository at this point in the history
* migrate to supa

* foreign key

* formatting

* removed useless logs
  • Loading branch information
armintalaie committed Apr 9, 2024
1 parent 75fdfaa commit 4a81309
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 3 additions & 3 deletions resources/database/migrations/1708560752.sql
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@ CREATE TABLE IF NOT EXISTS post (
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
contents JSON,
FOREIGN KEY (teamid) REFERENCES team(id) ON DELETE CASCADE,
FOREIGN KEY (userid) REFERENCES user(id) ON DELETE CASCADE
FOREIGN KEY (userid) REFERENCES person(id) ON DELETE CASCADE
);

CREATE TABLE IF NOT EXISTS team_member (
teamid INT NOT NULL,
userid INT NOT NULL,
team_role TEXT CHECK(team_role IN ('tech lead', 'developer', 'designer', 'design lead', 'other')) DEFAULT 'other',
member_since TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (teamid, userid)
PRIMARY KEY (teamid, userid),
FOREIGN KEY (teamid) REFERENCES team(id) ON DELETE CASCADE,
FOREIGN KEY (userid) REFERENCES user(id) ON DELETE CASCADE
FOREIGN KEY (userid) REFERENCES person(id) ON DELETE CASCADE
);
3 changes: 1 addition & 2 deletions resources/database/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const resetDatabase = async (client: Client): Promise<void> => {
console.log(
chalk.bold('Emptying database ' + chalk.bold.underline(DATABASE_NAME))
);
console.log(result.rows);

const tableNames = result.rows.map((table) => table.table_name);

if (tableNames.length > 0) {
Expand Down Expand Up @@ -203,7 +203,6 @@ const run = (): void => {
}
const client = new Client({ connectionString: connectionUrl });

console.log(client);
setUpDatabase(client, true)
.then(() => {
console.log(chalk.bgGreen('Database setup completed'));
Expand Down

0 comments on commit 4a81309

Please sign in to comment.