-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
5,748 additions
and
3,648 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
Binary file not shown.
25 changes: 25 additions & 0 deletions
25
awesome/database/migrations/20231018015225_025_create_UserTags_table.js
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,25 @@ | ||
const databaseOperations = require("../utils"); | ||
const { TABLES } = require("../constants"); | ||
|
||
const TABLE_NAME = TABLES.USER_TAGS; | ||
|
||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
exports.up = function (knex) { | ||
return databaseOperations.createTable(knex, TABLE_NAME, (table) => { | ||
table.string("id").primary().notNullable(); | ||
table.string("tagId").references("id").inTable(TABLES.TAG).notNullable(); | ||
table.string("userId").references("id").inTable(TABLES.USER).notNullable(); | ||
table.timestamps(true, true, true); | ||
}); | ||
}; | ||
|
||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
exports.down = function (knex) { | ||
return knex.schema.dropTable(TABLE_NAME); | ||
}; |
34 changes: 34 additions & 0 deletions
34
awesome/database/migrations/20231018022620_026_insert_directus_fields_for_UserTags_tables.js
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,34 @@ | ||
const { TABLES, DIRECTUS_TABLES } = require("../constants"); | ||
const directusUtil = require("../utils/directus") | ||
|
||
const TABLE_NAME=TABLES.USER_TAGS; | ||
|
||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
exports.up = async function (knex) { | ||
const exists = await knex.schema.hasTable(DIRECTUS_TABLES.DIRECTUS_FIELDS); | ||
if (exists) { | ||
await directusUtil.insertIdFields(knex, [TABLE_NAME]); | ||
await directusUtil.insertTimeFields(knex, [TABLE_NAME], "createdAt", "3"); | ||
await directusUtil.insertTimeFields(knex, [TABLE_NAME], "updatedAt", "4"); | ||
await directusUtil.insertForeignIdFields(knex, [TABLE_NAME], "userId", "{{name}}"); | ||
await directusUtil.insertForeignIdFields(knex, [TABLE_NAME], "tagId", "{{name}}"); | ||
} | ||
}; | ||
|
||
/** | ||
* @param { import("knex").Knex } knex | ||
* @returns { Promise<void> } | ||
*/ | ||
exports.down = async function (knex) { | ||
const exists = await knex.schema.hasTable(DIRECTUS_TABLES.DIRECTUS_FIELDS); | ||
if (exists) { | ||
await directusUtil.deleteField(knex, [TABLE_NAME], "id"); | ||
await directusUtil.deleteField(knex, [TABLE_NAME], "createdAt"); | ||
await directusUtil.deleteField(knex, [TABLE_NAME], "updatedAt"); | ||
await directusUtil.deleteField(knex, [TABLE_NAME], "userId"); | ||
await directusUtil.deleteField(knex, [TABLE_NAME], "tagId"); | ||
} | ||
}; |
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.