-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added weekly report * refactor for arrow functions and preferring named imports
- Loading branch information
Showing
102 changed files
with
1,470 additions
and
349 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
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
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,36 @@ | ||
const SQL = `--sql | ||
CREATE TABLE accounts_user ( | ||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, | ||
email varchar(255) UNIQUE, | ||
first_name varchar(255), | ||
last_name varchar(255), | ||
avatar_url varchar(255), | ||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP, | ||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP | ||
); | ||
` | ||
|
||
const SQL_SETTINGS = `--sql | ||
CREATE TABLE IF NOT EXISTS accounts_user_settings ( | ||
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, | ||
user_id INTEGER NOT NULL, | ||
weekly_report_type VARCHAR(255) NOT NULL DEFAULT '', | ||
created_at DATETIME DEFAULT CURRENT_TIMESTAMP, | ||
updated_at DATETIME DEFAULT CURRENT_TIMESTAMP, | ||
FOREIGN KEY (user_id) REFERENCES accounts_user (id) ON DELETE CASCADE | ||
); | ||
` | ||
|
||
exports.up = async function (knex) { | ||
await knex.raw(SQL) | ||
await knex.raw(SQL_SETTINGS) | ||
return | ||
} | ||
|
||
exports.down = function (knex) { | ||
return | ||
// return knex.raw(`--sql | ||
// DROP TABLE accounts_user; | ||
// `) | ||
} |
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,26 @@ | ||
exports.up = function(knex) { | ||
return knex.transaction(async (trx) => { | ||
// Insert into accounts_user | ||
await trx('accounts_user').insert({}); | ||
const [row] = await trx.raw('SELECT last_insert_rowid() as id'); | ||
const userId = row.id; | ||
// Insert into accounts_user_settings | ||
await trx('accounts_user_settings').insert({ | ||
user_id: userId | ||
}); | ||
}); | ||
}; | ||
|
||
exports.down = function(knex) { | ||
// return knex.transaction(async (trx) => { | ||
// // Remove the last inserted user_settings | ||
// await trx('accounts_user_settings') | ||
// .where('user_id', knex.raw('(SELECT MAX(id) FROM accounts_user)')) | ||
// .del(); | ||
|
||
// // Remove the last inserted user | ||
// await trx('accounts_user') | ||
// .where('id', knex.raw('(SELECT MAX(id) FROM accounts_user)')) | ||
// .del(); | ||
// }); | ||
}; |
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
Oops, something went wrong.