Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
reveurmichael committed Oct 20, 2023
2 parents d0c8435 + 42c4dd8 commit 5f80d7d
Show file tree
Hide file tree
Showing 33 changed files with 5,748 additions and 3,648 deletions.
3 changes: 2 additions & 1 deletion awesome/database/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const TABLES = {
COURSE_ORGANIZATIONS: "CourseOrganizations",
USER_COURSES: "UserCourses",
TUTORIAL_TAGS: "TutorialTags",
USER_TUTORIALS: "UserTutorials"
USER_TUTORIALS: "UserTutorials",
USER_TAGS: "UserTags",
};

const DIRECTUS_TABLES = {
Expand Down
Binary file modified awesome/database/data.db
Binary file not shown.
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);
};
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");
}
};
2 changes: 1 addition & 1 deletion awesome/database/utils/directus.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ async function insertForeignIdFields(
);
}

async function deleteFields(
async function deleteField(
knex,
tables,
field
Expand Down
Loading

0 comments on commit 5f80d7d

Please sign in to comment.