From e0bebee89de972f59a501aa75e82157b0b74267e Mon Sep 17 00:00:00 2001 From: Askar Yusupov Date: Mon, 29 May 2023 09:46:32 +0500 Subject: [PATCH 01/14] refactor(users.js): change camelCase column names to snake_case for consistency and readability update(users.js): change foreign key constraint name from 'fk_roleId' to 'fk_role_id' to follow naming convention --- db/migrations/20230526070609_users.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db/migrations/20230526070609_users.js b/db/migrations/20230526070609_users.js index adb86fc..0f850aa 100644 --- a/db/migrations/20230526070609_users.js +++ b/db/migrations/20230526070609_users.js @@ -14,13 +14,13 @@ exports.up = function (knex) { return knex.schema.createTable(USERS_TABLE, (table) => { table.increments('id'); table.string('password', PASSWORD_LENGTH).nullable(); - table.string('firstName', NAME_LENGTH); - table.string('lastName', NAME_LENGTH); - table.integer('roleId', FOREIGN_KEY_LENGTH).unsigned().index(); + table.string('first_name', NAME_LENGTH); + table.string('last_name', NAME_LENGTH); + table.integer('role_id', FOREIGN_KEY_LENGTH).unsigned().index(); table.timestamps(false, true, true); table - .foreign('roleId', 'fk_roleId') + .foreign('role_id', 'fk_role_id') .references('id') .inTable(USER_ROLES_TABLE) .onDelete('CASCADE'); From b3a4cf21977bce11ba1aa3a5fd51e272c6c2923c Mon Sep 17 00:00:00 2001 From: Askar Yusupov Date: Mon, 29 May 2023 09:49:08 +0500 Subject: [PATCH 02/14] refactor(user-api-tokens.js): change userId column name to user_id to follow snake_case naming convention refactor(user-api-tokens.js): change foreign key constraint name from fk_userId to fk_user_id to follow snake_case naming convention --- db/migrations/20230526071428_user-api-tokens.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/migrations/20230526071428_user-api-tokens.js b/db/migrations/20230526071428_user-api-tokens.js index 72407fe..db9fa10 100644 --- a/db/migrations/20230526071428_user-api-tokens.js +++ b/db/migrations/20230526071428_user-api-tokens.js @@ -7,13 +7,13 @@ const { USERS_TABLE, USER_API_TOKENS_TABLE, FOREIGN_KEY_LENGTH } = require('../. exports.up = function (knex) { return knex.schema.createTable(USER_API_TOKENS_TABLE, (table) => { table.increments('id'); - table.integer('userId', FOREIGN_KEY_LENGTH).unsigned().index(); + table.integer('user_id', FOREIGN_KEY_LENGTH).unsigned().index(); table.string('token').unique(); table.timestamps(false, true, true); table.primary('id', { constraintName: 'pk_user_api_token' }); table - .foreign('userId', 'fk_userId') + .foreign('user_id', 'fk_user_id') .references('id') .inTable(USERS_TABLE) .onDelete('CASCADE'); From a42618b6d819d8f2668c1dfb6d3805c652962841 Mon Sep 17 00:00:00 2001 From: Askar Yusupov Date: Mon, 29 May 2023 09:51:21 +0500 Subject: [PATCH 03/14] refactor(users-emails.js): change userId column name to user_id to follow snake_case naming convention refactor(users-emails.js): change primary key constraint name to follow snake_case naming convention refactor(users-emails.js): change foreign key constraint name to follow snake_case naming convention feat(users-emails.js): add verified column to track if email is verified or not --- db/migrations/20230526071911_users-emails.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/db/migrations/20230526071911_users-emails.js b/db/migrations/20230526071911_users-emails.js index 97860f7..29fd876 100644 --- a/db/migrations/20230526071911_users-emails.js +++ b/db/migrations/20230526071911_users-emails.js @@ -12,15 +12,15 @@ const { */ exports.up = function (knex) { return knex.schema.createTable(USERS_EMAILS_TABLE, (table) => { - table.integer('userId', FOREIGN_KEY_LENGTH).unsigned().index(); + table.integer('user_id', FOREIGN_KEY_LENGTH).unsigned().index(); table.string('email', EMAIL_LENGTH).unique().index(); table.string('code', PASSWORD_LENGTH).unique().index(); table.boolean('verified').defaultTo(false); table.timestamps(false, true, true); - table.primary(['userId', 'email'], { constraintName: 'pk_user_email' }); + table.primary(['user_id', 'email'], { constraintName: 'pk_user_email' }); table - .foreign('userId', 'fk_userId') + .foreign('user_id', 'fk_user_id') .references('id') .inTable(USERS_TABLE) .onDelete('CASCADE'); From ae2ec94f9358a76011d4c2f086c8e549dd33a68f Mon Sep 17 00:00:00 2001 From: Askar Yusupov Date: Mon, 29 May 2023 09:53:31 +0500 Subject: [PATCH 04/14] refactor(users-oauths.js): change column names to snake_case for consistency and readability --- db/migrations/20230526072327_users-oauths.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db/migrations/20230526072327_users-oauths.js b/db/migrations/20230526072327_users-oauths.js index 85d0711..d4f0510 100644 --- a/db/migrations/20230526072327_users-oauths.js +++ b/db/migrations/20230526072327_users-oauths.js @@ -13,20 +13,20 @@ const OAUTH_PROVIDERS_ENUM_NAME = 'oauth_providers'; */ exports.up = function (knex) { return knex.schema.createTable(USERS_OAUTHS_TABLE, (table) => { - table.integer('userId', FOREIGN_KEY_LENGTH).unsigned().index(); + table.integer('user_id', FOREIGN_KEY_LENGTH).unsigned().index(); table.enu('provider', OAUTH_PROVIDERS_ENUM, { useNative: true, enumName: OAUTH_PROVIDERS_ENUM_NAME, }); - table.string('providerId').unique(); + table.string('provider_id').unique(); table.jsonb('profile').nullable(); table.timestamps(false, true, true); - table.primary(['userId', 'provider'], { + table.primary(['user_id', 'provider'], { constraintName: 'pk_user_provider', }); table - .foreign('userId', 'fk_userId') + .foreign('user_id', 'fk_user_id') .references('id') .inTable(USERS_TABLE) .onDelete('CASCADE'); From f5cfe44ca89586a29c381a87b044615e70a36318 Mon Sep 17 00:00:00 2001 From: Askar Yusupov Date: Mon, 29 May 2023 09:55:38 +0500 Subject: [PATCH 05/14] refactor(user-calculations.js): change userId column name to user_id to follow snake_case naming convention and improve readability refactor(user-calculations.js): change foreign key constraint name from fk_userId to fk_user_id to follow snake_case naming convention and improve readability --- db/migrations/20230526072716_user-calculations.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/migrations/20230526072716_user-calculations.js b/db/migrations/20230526072716_user-calculations.js index 3d2170c..693af29 100644 --- a/db/migrations/20230526072716_user-calculations.js +++ b/db/migrations/20230526072716_user-calculations.js @@ -7,12 +7,12 @@ const { USERS_TABLE, USER_CALCULATIONS_TABLE, FOREIGN_KEY_LENGTH } = require('.. exports.up = function (knex) { return knex.schema.createTable(USER_CALCULATIONS_TABLE, (table) => { table.increments('id'); - table.integer('userId', FOREIGN_KEY_LENGTH).unsigned().index(); + table.integer('user_id', FOREIGN_KEY_LENGTH).unsigned().index(); table.uuid('uuid').unique(); table.timestamps(false, true, true); table - .foreign('userId', 'fk_userId') + .foreign('user_id', 'fk_user_id') .references('id') .inTable(USERS_TABLE) .onDelete('CASCADE'); From 4e536a1c950f779c796fd6a20afc02856a3ae74c Mon Sep 17 00:00:00 2001 From: Askar Yusupov Date: Mon, 29 May 2023 09:57:13 +0500 Subject: [PATCH 06/14] refactor(user-datasources.js): change userId column name to user_id to follow snake_case naming convention and improve readability refactor(user-datasources.js): change foreign key name from fk_userId to fk_user_id to follow snake_case naming convention and improve readability --- db/migrations/20230526073013_user-datasources.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/migrations/20230526073013_user-datasources.js b/db/migrations/20230526073013_user-datasources.js index d363a7c..de89561 100644 --- a/db/migrations/20230526073013_user-datasources.js +++ b/db/migrations/20230526073013_user-datasources.js @@ -7,12 +7,12 @@ const { USERS_TABLE, USER_DATASOURCES_TABLE, FOREIGN_KEY_LENGTH } = require('../ exports.up = function (knex) { return knex.schema.createTable(USER_DATASOURCES_TABLE, (table) => { table.increments('id'); - table.integer('userId', FOREIGN_KEY_LENGTH).unsigned().index(); + table.integer('user_id', FOREIGN_KEY_LENGTH).unsigned().index(); table.uuid('uuid').unique(); table.timestamps(false, true, true); table - .foreign('userId', 'fk_userId') + .foreign('user_id', 'fk_user_id') .references('id') .inTable(USERS_TABLE) .onDelete('CASCADE'); From ea84783029fd48f2fe207497d339094fe5b359e9 Mon Sep 17 00:00:00 2001 From: Askar Yusupov Date: Mon, 29 May 2023 09:59:02 +0500 Subject: [PATCH 07/14] refactor(user-collections.js): change column names to snake_case for consistency and readability --- db/migrations/20230526073335_user-collections.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/db/migrations/20230526073335_user-collections.js b/db/migrations/20230526073335_user-collections.js index 903c387..5bb31f5 100644 --- a/db/migrations/20230526073335_user-collections.js +++ b/db/migrations/20230526073335_user-collections.js @@ -15,8 +15,8 @@ const VISIBILITY_ENUM_NAME = 'collection_visibility'; exports.up = function (knex) { return knex.schema.createTable(USER_COLLECTIONS_TABLE, (table) => { table.increments('id'); - table.integer('userId', FOREIGN_KEY_LENGTH).unsigned().index(); - table.integer('typeId', FOREIGN_KEY_LENGTH).unsigned().index(); + table.integer('user_id', FOREIGN_KEY_LENGTH).unsigned().index(); + table.integer('type_id', FOREIGN_KEY_LENGTH).unsigned().index(); table.string('title', 32); table.string('description', 64); table @@ -28,12 +28,12 @@ exports.up = function (knex) { table.timestamps(false, true, true); table - .foreign('userId', 'fk_userId') + .foreign('user_id', 'fk_user_id') .references('id') .inTable(USERS_TABLE) .onDelete('CASCADE'); table - .foreign('typeId', 'fk_typeId') + .foreign('type_id', 'fk_type_id') .references('id') .inTable(COLLECTIONS_TYPES_TABLE) .onDelete('CASCADE'); From 95a40a98ab514c53c2475c0c943a3a8f0b9cce7c Mon Sep 17 00:00:00 2001 From: Askar Yusupov Date: Mon, 29 May 2023 10:00:44 +0500 Subject: [PATCH 08/14] refactor(user-shared-collections.js): change column names to snake_case for consistency and readability feat(user-shared-collections.js): add foreign key constraint names for clarity and easier debugging --- .../20230526073811_user-shared-collections.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/db/migrations/20230526073811_user-shared-collections.js b/db/migrations/20230526073811_user-shared-collections.js index fa2ed66..c55c358 100644 --- a/db/migrations/20230526073811_user-shared-collections.js +++ b/db/migrations/20230526073811_user-shared-collections.js @@ -11,21 +11,21 @@ const { */ exports.up = function (knex) { return knex.schema.createTable(USER_SHARED_COLLECTIONS_TABLE, (table) => { - table.integer('collectionId', FOREIGN_KEY_LENGTH).unsigned().index(); - table.integer('userId', FOREIGN_KEY_LENGTH).unsigned().index(); + table.integer('collection_id', FOREIGN_KEY_LENGTH).unsigned().index(); + table.integer('user_id', FOREIGN_KEY_LENGTH).unsigned().index(); table.jsonb('permissions').nullable(); table.timestamps(false, true, true); - table.primary(['userId', 'collectionId'], { + table.primary(['user_id', 'collection_id'], { constraintName: 'pk_user_collection', }); table - .foreign('userId', 'fk_userId') + .foreign('user_id', 'fk_user_id') .references('id') .inTable(USERS_TABLE) .onDelete('CASCADE'); table - .foreign('collectionId', 'fk_collectionId') + .foreign('collection_id', 'fk_collection_id') .references('id') .inTable(USER_COLLECTIONS_TABLE) .onDelete('CASCADE'); From 878c8199d0cc9ddf5260d84cbed2ac02c4c1ab3b Mon Sep 17 00:00:00 2001 From: Askar Yusupov Date: Mon, 29 May 2023 10:02:19 +0500 Subject: [PATCH 09/14] refactor(migrations): change column names in user_collections_datasources table to snake_case for consistency and readability --- .../20230526074155_user-collections-datasources.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/db/migrations/20230526074155_user-collections-datasources.js b/db/migrations/20230526074155_user-collections-datasources.js index 8f0a083..ea44a40 100644 --- a/db/migrations/20230526074155_user-collections-datasources.js +++ b/db/migrations/20230526074155_user-collections-datasources.js @@ -10,20 +10,20 @@ const { */ exports.up = function (knex) { return knex.schema.createTable(USER_COLLECTIONS_DATASOURCES_TABLE, (table) => { - table.integer('collectionId').unsigned().index(); - table.integer('dataSourceId').unsigned().index(); + table.integer('collection_id').unsigned().index(); + table.integer('data_source_id').unsigned().index(); table.timestamps(false, true, true); - table.primary(['collectionId', 'dataSourceId'], { - constraintName: 'pk_collection_dataSource', + table.primary(['collection_id', 'data_source_id'], { + constraintName: 'pk_collection_data_source', }); table - .foreign('collectionId', 'fk_collectionId') + .foreign('collection_id', 'fk_collection_id') .references('id') .inTable(USER_COLLECTIONS_TABLE) .onDelete('CASCADE'); table - .foreign('dataSourceId', 'fk_dataSourceId') + .foreign('data_source_id', 'fk_data_source_id') .references('id') .inTable(USER_DATASOURCES_TABLE) .onDelete('CASCADE'); From c46327a198324a255f5f653a0ae7422210913678 Mon Sep 17 00:00:00 2001 From: Askar Yusupov Date: Mon, 29 May 2023 10:07:05 +0500 Subject: [PATCH 10/14] refactor(logs.js): change column names to snake_case for consistency and readability feat(logs.js): change trigger function to use new column name 'user_id' instead of 'userId' to match schema --- db/migrations/20230526074529_logs.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/db/migrations/20230526074529_logs.js b/db/migrations/20230526074529_logs.js index 2d417e8..d274cd5 100644 --- a/db/migrations/20230526074529_logs.js +++ b/db/migrations/20230526074529_logs.js @@ -24,10 +24,10 @@ exports.up = function (knex) { return knex.schema .createTable(LOGS_TABLE, (table) => { table.increments('id'); - table.integer('userId').unsigned().index(); + table.integer('user_id').unsigned().index(); table.string('type'); table.jsonb('value'); - table.timestamp('createdAt').defaultTo(knex.fn.now()).index(); + table.timestamp('created_at').defaultTo(knex.fn.now()).index(); table.primary('id', { constraintName: 'pk_logs' }); }) @@ -36,15 +36,15 @@ exports.up = function (knex) { const query = ` create or replace function ${LOG_FUNCTION} () returns trigger as $$ declare - userId integer; + user_id integer; type varchar := lower(tg_table_name); begin if type = lower('${USERS_TABLE}') then - userId := new.id; + user_id := new.id; else - userId := new."userId"; + user_id := new."user_id"; end if; - insert into "${LOGS_TABLE}" ("userId", "type", "value") values (userId, type, to_jsonb(new)); + insert into "${LOGS_TABLE}" ("user_id", "type", "value") values (user_id, type, to_jsonb(new)); return new; end; $$ language plpgsql; From c17c84ebe4251a48dd115d0151df1404a18a266b Mon Sep 17 00:00:00 2001 From: Askar Yusupov Date: Mon, 29 May 2023 10:12:19 +0500 Subject: [PATCH 11/14] refactor: timestamps to snake_case --- db/migrations/20230526065020_user-roles.js | 2 +- db/migrations/20230526070609_users.js | 2 +- db/migrations/20230526071428_user-api-tokens.js | 2 +- db/migrations/20230526071911_users-emails.js | 2 +- db/migrations/20230526072327_users-oauths.js | 2 +- db/migrations/20230526072716_user-calculations.js | 2 +- db/migrations/20230526073013_user-datasources.js | 2 +- db/migrations/20230526073335_user-collections.js | 2 +- db/migrations/20230526073811_user-shared-collections.js | 2 +- db/migrations/20230526074155_user-collections-datasources.js | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/db/migrations/20230526065020_user-roles.js b/db/migrations/20230526065020_user-roles.js index d1280f9..652f43f 100644 --- a/db/migrations/20230526065020_user-roles.js +++ b/db/migrations/20230526065020_user-roles.js @@ -10,7 +10,7 @@ exports.up = function (knex) { table.string('slug', NAME_LENGTH).unique(); table.string('label', NAME_LENGTH); table.jsonb('permissions').nullable(); - table.timestamps(false, true, true); + table.timestamps(false, true, false); }); }; diff --git a/db/migrations/20230526070609_users.js b/db/migrations/20230526070609_users.js index 0f850aa..bcd0626 100644 --- a/db/migrations/20230526070609_users.js +++ b/db/migrations/20230526070609_users.js @@ -17,7 +17,7 @@ exports.up = function (knex) { table.string('first_name', NAME_LENGTH); table.string('last_name', NAME_LENGTH); table.integer('role_id', FOREIGN_KEY_LENGTH).unsigned().index(); - table.timestamps(false, true, true); + table.timestamps(false, true, false); table .foreign('role_id', 'fk_role_id') diff --git a/db/migrations/20230526071428_user-api-tokens.js b/db/migrations/20230526071428_user-api-tokens.js index db9fa10..5d67845 100644 --- a/db/migrations/20230526071428_user-api-tokens.js +++ b/db/migrations/20230526071428_user-api-tokens.js @@ -9,7 +9,7 @@ exports.up = function (knex) { table.increments('id'); table.integer('user_id', FOREIGN_KEY_LENGTH).unsigned().index(); table.string('token').unique(); - table.timestamps(false, true, true); + table.timestamps(false, true, false); table.primary('id', { constraintName: 'pk_user_api_token' }); table diff --git a/db/migrations/20230526071911_users-emails.js b/db/migrations/20230526071911_users-emails.js index 29fd876..a33cd27 100644 --- a/db/migrations/20230526071911_users-emails.js +++ b/db/migrations/20230526071911_users-emails.js @@ -16,7 +16,7 @@ exports.up = function (knex) { table.string('email', EMAIL_LENGTH).unique().index(); table.string('code', PASSWORD_LENGTH).unique().index(); table.boolean('verified').defaultTo(false); - table.timestamps(false, true, true); + table.timestamps(false, true, false); table.primary(['user_id', 'email'], { constraintName: 'pk_user_email' }); table diff --git a/db/migrations/20230526072327_users-oauths.js b/db/migrations/20230526072327_users-oauths.js index d4f0510..05957dc 100644 --- a/db/migrations/20230526072327_users-oauths.js +++ b/db/migrations/20230526072327_users-oauths.js @@ -20,7 +20,7 @@ exports.up = function (knex) { }); table.string('provider_id').unique(); table.jsonb('profile').nullable(); - table.timestamps(false, true, true); + table.timestamps(false, true, false); table.primary(['user_id', 'provider'], { constraintName: 'pk_user_provider', diff --git a/db/migrations/20230526072716_user-calculations.js b/db/migrations/20230526072716_user-calculations.js index 693af29..5205e3f 100644 --- a/db/migrations/20230526072716_user-calculations.js +++ b/db/migrations/20230526072716_user-calculations.js @@ -9,7 +9,7 @@ exports.up = function (knex) { table.increments('id'); table.integer('user_id', FOREIGN_KEY_LENGTH).unsigned().index(); table.uuid('uuid').unique(); - table.timestamps(false, true, true); + table.timestamps(false, true, false); table .foreign('user_id', 'fk_user_id') diff --git a/db/migrations/20230526073013_user-datasources.js b/db/migrations/20230526073013_user-datasources.js index de89561..c2a48dc 100644 --- a/db/migrations/20230526073013_user-datasources.js +++ b/db/migrations/20230526073013_user-datasources.js @@ -9,7 +9,7 @@ exports.up = function (knex) { table.increments('id'); table.integer('user_id', FOREIGN_KEY_LENGTH).unsigned().index(); table.uuid('uuid').unique(); - table.timestamps(false, true, true); + table.timestamps(false, true, false); table .foreign('user_id', 'fk_user_id') diff --git a/db/migrations/20230526073335_user-collections.js b/db/migrations/20230526073335_user-collections.js index 5bb31f5..9357899 100644 --- a/db/migrations/20230526073335_user-collections.js +++ b/db/migrations/20230526073335_user-collections.js @@ -25,7 +25,7 @@ exports.up = function (knex) { enumName: VISIBILITY_ENUM_NAME, }) .defaultTo(VISIBILITY_ENUM[0]); - table.timestamps(false, true, true); + table.timestamps(false, true, false); table .foreign('user_id', 'fk_user_id') diff --git a/db/migrations/20230526073811_user-shared-collections.js b/db/migrations/20230526073811_user-shared-collections.js index c55c358..a3e06de 100644 --- a/db/migrations/20230526073811_user-shared-collections.js +++ b/db/migrations/20230526073811_user-shared-collections.js @@ -14,7 +14,7 @@ exports.up = function (knex) { table.integer('collection_id', FOREIGN_KEY_LENGTH).unsigned().index(); table.integer('user_id', FOREIGN_KEY_LENGTH).unsigned().index(); table.jsonb('permissions').nullable(); - table.timestamps(false, true, true); + table.timestamps(false, true, false); table.primary(['user_id', 'collection_id'], { constraintName: 'pk_user_collection', diff --git a/db/migrations/20230526074155_user-collections-datasources.js b/db/migrations/20230526074155_user-collections-datasources.js index ea44a40..62a154e 100644 --- a/db/migrations/20230526074155_user-collections-datasources.js +++ b/db/migrations/20230526074155_user-collections-datasources.js @@ -12,7 +12,7 @@ exports.up = function (knex) { return knex.schema.createTable(USER_COLLECTIONS_DATASOURCES_TABLE, (table) => { table.integer('collection_id').unsigned().index(); table.integer('data_source_id').unsigned().index(); - table.timestamps(false, true, true); + table.timestamps(false, true, false); table.primary(['collection_id', 'data_source_id'], { constraintName: 'pk_collection_data_source', From 7998e6ee690f8ae8ccdcdd723ee58de7702df32b Mon Sep 17 00:00:00 2001 From: Askar Yusupov Date: Mon, 29 May 2023 10:13:28 +0500 Subject: [PATCH 12/14] refactor: timestamps to snake_case --- db/migrations/20230526063604_collections-types.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/migrations/20230526063604_collections-types.js b/db/migrations/20230526063604_collections-types.js index 6c14c94..f805ada 100644 --- a/db/migrations/20230526063604_collections-types.js +++ b/db/migrations/20230526063604_collections-types.js @@ -15,7 +15,7 @@ exports.up = function (knex) { useNative: true, enumName: FLAVORS_ENUM_NAME, }); - table.timestamps(false, true, true); + table.timestamps(false, true, false); }); }; From b1a6fa503257592d220d415e0eb08e6403883149 Mon Sep 17 00:00:00 2001 From: Askar Yusupov Date: Mon, 29 May 2023 10:17:26 +0500 Subject: [PATCH 13/14] refactor(users.js): change camelCase to snake_case for column names in users and users_emails tables to match database naming convention --- db/seeds/030-users.js | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/db/seeds/030-users.js b/db/seeds/030-users.js index 3bd6ead..9f92855 100644 --- a/db/seeds/030-users.js +++ b/db/seeds/030-users.js @@ -23,21 +23,21 @@ exports.seed = async function (knex) { const [member, admin, test] = await knex(USERS_TABLE).insert( [ { - firstName: 'Test', - lastName: 'Member', - roleId: memberRole.id, + first_name: 'Test', + last_name: 'Member', + role_id: memberRole.id, password, }, { - firstName: 'Test', - lastName: 'Admin', - roleId: adminRole.id, + first_name: 'Test', + last_name: 'Admin', + role_id: adminRole.id, password, }, { - firstName: 'Test', - lastName: 'Test', - roleId: memberRole.id, + first_name: 'Test', + last_name: 'Test', + role_id: memberRole.id, password, }, ], @@ -57,17 +57,17 @@ exports.seed = async function (knex) { await knex(USERS_EMAILS_TABLE).insert([ { - userId: member.id, + user_id: member.id, email: memberEmail, code: code1, }, { - userId: admin.id, + user_id: admin.id, email: adminEmail, code: code2, }, { - userId: test.id, + user_id: test.id, email: testEmail, code: code3, }, From 7d2e933b16dbf52f13b23c8cf9885fda03184b04 Mon Sep 17 00:00:00 2001 From: Askar Yusupov Date: Mon, 29 May 2023 10:20:14 +0500 Subject: [PATCH 14/14] refactor(seeds): change user_id property name to snake_case to match database column naming convention --- db/seeds/040-user-api-tokens.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/seeds/040-user-api-tokens.js b/db/seeds/040-user-api-tokens.js index 410d724..f991e36 100644 --- a/db/seeds/040-user-api-tokens.js +++ b/db/seeds/040-user-api-tokens.js @@ -10,8 +10,8 @@ exports.seed = async function (knex) { // Deletes ALL existing entries await knex(USER_API_TOKENS_TABLE).del(); await knex(USER_API_TOKENS_TABLE).insert( - emails.map(({ userId, email }) => ({ - userId, + emails.map(({ user_id, email }) => ({ + user_id, token: email, // inserting email as token just for test })) );