From 7584d2d7a7110aef0331ebfa178b2295842c59fa Mon Sep 17 00:00:00 2001 From: MCMXC <16797721+mcmxcdev@users.noreply.github.com> Date: Sat, 10 Feb 2024 18:19:14 -0700 Subject: refactor: project maintenance - work in progress --- database/migrations/1503250034279_user.ts | 22 +++++++------- database/migrations/1503250034280_token.ts | 22 +++++++------- .../migrations/1566385379883_service_schema.ts | 24 +++++++-------- database/migrations/1566554231482_recipe_schema.ts | 20 ++++++------- .../migrations/1566554359294_workspace_schema.ts | 26 ++++++++--------- .../1612629845398_users_update_schema.ts | 14 ++++----- .../1658076326250_correct_token_relations.ts | 16 +++++----- database/migrations/1696110557648_jwt_tokens.ts | 34 +++++++++------------- 8 files changed, 85 insertions(+), 93 deletions(-) (limited to 'database/migrations') diff --git a/database/migrations/1503250034279_user.ts b/database/migrations/1503250034279_user.ts index 262a472..4a58213 100644 --- a/database/migrations/1503250034279_user.ts +++ b/database/migrations/1503250034279_user.ts @@ -1,20 +1,20 @@ -import BaseSchema from '@ioc:Adonis/Lucid/Schema'; +import { BaseSchema } from '@adonisjs/lucid/schema' export default class extends BaseSchema { - protected tableName = 'users'; + protected tableName = 'users' public async up(): Promise { - this.schema.createTable(this.tableName, table => { - table.increments(); - table.string('username', 80).notNullable(); - table.string('email', 254).notNullable().unique(); - table.string('password', 60).notNullable(); - table.json('settings'); - table.timestamps(); - }); + this.schema.createTable(this.tableName, (table) => { + table.increments() + table.string('username', 80).notNullable() + table.string('email', 254).notNullable().unique() + table.string('password', 60).notNullable() + table.json('settings') + table.timestamps() + }) } public async down(): Promise { - this.schema.dropTable(this.tableName); + this.schema.dropTable(this.tableName) } } diff --git a/database/migrations/1503250034280_token.ts b/database/migrations/1503250034280_token.ts index 5a030d0..3830c98 100644 --- a/database/migrations/1503250034280_token.ts +++ b/database/migrations/1503250034280_token.ts @@ -1,20 +1,20 @@ -import BaseSchema from '@ioc:Adonis/Lucid/Schema'; +import { BaseSchema } from '@adonisjs/lucid/schema' export default class extends BaseSchema { - protected tableName = 'tokens'; + protected tableName = 'tokens' public async up(): Promise { - this.schema.createTable(this.tableName, table => { - table.increments(); - table.integer('user_id').unsigned().references('users.id'); - table.string('token', 255).notNullable().unique().index(); - table.string('type', 80).notNullable(); - table.boolean('is_revoked').defaultTo(false); - table.timestamps(); - }); + this.schema.createTable(this.tableName, (table) => { + table.increments() + table.integer('user_id').unsigned().references('users.id') + table.string('token', 255).notNullable().unique().index() + table.string('type', 80).notNullable() + table.boolean('is_revoked').defaultTo(false) + table.timestamps() + }) } public async down(): Promise { - this.schema.dropTable(this.tableName); + this.schema.dropTable(this.tableName) } } diff --git a/database/migrations/1566385379883_service_schema.ts b/database/migrations/1566385379883_service_schema.ts index 9c3e23d..3c46cab 100644 --- a/database/migrations/1566385379883_service_schema.ts +++ b/database/migrations/1566385379883_service_schema.ts @@ -1,21 +1,21 @@ -import BaseSchema from '@ioc:Adonis/Lucid/Schema'; +import { BaseSchema } from '@adonisjs/lucid/schema' export default class extends BaseSchema { - protected tableName = 'services'; + protected tableName = 'services' public async up(): Promise { - this.schema.createTable(this.tableName, table => { - table.increments(); - table.string('userId', 80).notNullable(); - table.string('serviceId', 80).notNullable(); - table.string('name', 80).notNullable(); - table.string('recipeId', 254).notNullable(); - table.json('settings'); - table.timestamps(); - }); + this.schema.createTable(this.tableName, (table) => { + table.increments() + table.string('userId', 80).notNullable() + table.string('serviceId', 80).notNullable() + table.string('name', 80).notNullable() + table.string('recipeId', 254).notNullable() + table.json('settings') + table.timestamps() + }) } public async down(): Promise { - this.schema.dropTable(this.tableName); + this.schema.dropTable(this.tableName) } } diff --git a/database/migrations/1566554231482_recipe_schema.ts b/database/migrations/1566554231482_recipe_schema.ts index 3a9784d..567c89f 100644 --- a/database/migrations/1566554231482_recipe_schema.ts +++ b/database/migrations/1566554231482_recipe_schema.ts @@ -1,19 +1,19 @@ -import BaseSchema from '@ioc:Adonis/Lucid/Schema'; +import { BaseSchema } from '@adonisjs/lucid/schema' export default class extends BaseSchema { - protected tableName = 'recipes'; + protected tableName = 'recipes' public async up(): Promise { - this.schema.createTable(this.tableName, table => { - table.increments(); - table.string('name', 80).notNullable(); - table.string('recipeId', 254).notNullable().unique(); - table.json('data'); - table.timestamps(); - }); + this.schema.createTable(this.tableName, (table) => { + table.increments() + table.string('name', 80).notNullable() + table.string('recipeId', 254).notNullable().unique() + table.json('data') + table.timestamps() + }) } public async down(): Promise { - this.schema.dropTable(this.tableName); + this.schema.dropTable(this.tableName) } } diff --git a/database/migrations/1566554359294_workspace_schema.ts b/database/migrations/1566554359294_workspace_schema.ts index 77e1189..b863200 100644 --- a/database/migrations/1566554359294_workspace_schema.ts +++ b/database/migrations/1566554359294_workspace_schema.ts @@ -1,22 +1,22 @@ -import BaseSchema from '@ioc:Adonis/Lucid/Schema'; +import { BaseSchema } from '@adonisjs/lucid/schema' export default class extends BaseSchema { - protected tableName = 'workspaces'; + protected tableName = 'workspaces' public async up(): Promise { - this.schema.createTable(this.tableName, table => { - table.increments(); - table.string('workspaceId', 80).notNullable().unique(); - table.string('userId', 80).notNullable(); - table.string('name', 80).notNullable(); - table.integer('order'); - table.json('services'); - table.json('data'); - table.timestamps(); - }); + this.schema.createTable(this.tableName, (table) => { + table.increments() + table.string('workspaceId', 80).notNullable().unique() + table.string('userId', 80).notNullable() + table.string('name', 80).notNullable() + table.integer('order') + table.json('services') + table.json('data') + table.timestamps() + }) } public async down(): Promise { - this.schema.dropTable(this.tableName); + this.schema.dropTable(this.tableName) } } diff --git a/database/migrations/1612629845398_users_update_schema.ts b/database/migrations/1612629845398_users_update_schema.ts index 8831ea4..76dc816 100644 --- a/database/migrations/1612629845398_users_update_schema.ts +++ b/database/migrations/1612629845398_users_update_schema.ts @@ -1,15 +1,15 @@ -import BaseSchema from '@ioc:Adonis/Lucid/Schema'; +import { BaseSchema } from '@adonisjs/lucid/schema' export default class extends BaseSchema { public async up(): Promise { - this.schema.alterTable('users', table => { - table.string('lastname', 80).notNullable().defaultTo(''); - }); + this.schema.alterTable('users', (table) => { + table.string('lastname', 80).notNullable().defaultTo('') + }) } public async down(): Promise { - this.schema.alterTable('users', table => { - table.dropColumn('lastname'); - }); + this.schema.alterTable('users', (table) => { + table.dropColumn('lastname') + }) } } diff --git a/database/migrations/1658076326250_correct_token_relations.ts b/database/migrations/1658076326250_correct_token_relations.ts index 5486657..1013861 100644 --- a/database/migrations/1658076326250_correct_token_relations.ts +++ b/database/migrations/1658076326250_correct_token_relations.ts @@ -1,18 +1,16 @@ -import BaseSchema from '@ioc:Adonis/Lucid/Schema'; +import { BaseSchema } from '@adonisjs/lucid/schema' export default class extends BaseSchema { - protected tableName = 'tokens'; + protected tableName = 'tokens' public async up(): Promise { - await this.db.rawQuery( - 'DELETE FROM tokens WHERE user_id NOT IN (SELECT id FROM users)', - ); + await this.db.rawQuery('DELETE FROM tokens WHERE user_id NOT IN (SELECT id FROM users)') - this.schema.alterTable(this.tableName, table => { - table.dropForeign('user_id'); + this.schema.alterTable(this.tableName, (table) => { + table.dropForeign('user_id') - table.foreign('user_id').references('users.id').onDelete('cascade'); - }); + table.foreign('user_id').references('users.id').onDelete('cascade') + }) } public async down(): Promise { diff --git a/database/migrations/1696110557648_jwt_tokens.ts b/database/migrations/1696110557648_jwt_tokens.ts index 9400de7..7823283 100644 --- a/database/migrations/1696110557648_jwt_tokens.ts +++ b/database/migrations/1696110557648_jwt_tokens.ts @@ -1,29 +1,23 @@ -import BaseSchema from '@ioc:Adonis/Lucid/Schema'; +import { BaseSchema } from '@adonisjs/lucid/schema' export default class JwtTokens extends BaseSchema { - protected tableName = 'jwt_tokens'; + protected tableName = 'jwt_tokens' public async up() { - this.schema.createTable(this.tableName, table => { - table.increments('id').primary(); - table - .integer('user_id') - .unsigned() - .references('users.id') - .onDelete('CASCADE'); - table.string('name').notNullable(); - table.string('type').notNullable(); - table.string('token', 64).notNullable().unique(); - table.timestamp('expires_at', { useTz: true }).nullable(); - table.string('refresh_token').notNullable().unique().index(); - table - .timestamp('refresh_token_expires_at', { useTz: true }) - .notNullable(); - table.timestamp('created_at', { useTz: true }).notNullable(); - }); + this.schema.createTable(this.tableName, (table) => { + table.increments('id').primary() + table.integer('user_id').unsigned().references('users.id').onDelete('CASCADE') + table.string('name').notNullable() + table.string('type').notNullable() + table.string('token', 64).notNullable().unique() + table.timestamp('expires_at', { useTz: true }).nullable() + table.string('refresh_token').notNullable().unique().index() + table.timestamp('refresh_token_expires_at', { useTz: true }).notNullable() + table.timestamp('created_at', { useTz: true }).notNullable() + }) } public async down() { - this.schema.dropTable(this.tableName); + this.schema.dropTable(this.tableName) } } -- cgit v1.2.3-70-g09d2