diff options
author | MCMXC <16797721+mcmxcdev@users.noreply.github.com> | 2024-02-10 18:37:40 -0700 |
---|---|---|
committer | Vijay A <vraravam@users.noreply.github.com> | 2024-02-17 21:54:14 +0530 |
commit | fb4d4f7781f2e0830897e1599535c83526b4c286 (patch) | |
tree | 78ed8d88587bba40396b1ae5f88bbf26a53a80dc /database/migrations | |
parent | refactor: project maintenance (diff) | |
download | ferdium-server-fb4d4f7781f2e0830897e1599535c83526b4c286.tar.gz ferdium-server-fb4d4f7781f2e0830897e1599535c83526b4c286.tar.zst ferdium-server-fb4d4f7781f2e0830897e1599535c83526b4c286.zip |
updates
Diffstat (limited to 'database/migrations')
-rw-r--r-- | database/migrations/1503250034279_user.ts | 22 | ||||
-rw-r--r-- | database/migrations/1503250034280_token.ts | 22 | ||||
-rw-r--r-- | database/migrations/1566385379883_service_schema.ts | 24 | ||||
-rw-r--r-- | database/migrations/1566554231482_recipe_schema.ts | 20 | ||||
-rw-r--r-- | database/migrations/1566554359294_workspace_schema.ts | 26 | ||||
-rw-r--r-- | database/migrations/1612629845398_users_update_schema.ts | 14 | ||||
-rw-r--r-- | database/migrations/1658076326250_correct_token_relations.ts | 16 | ||||
-rw-r--r-- | database/migrations/1696110557648_jwt_tokens.ts | 34 |
8 files changed, 93 insertions, 85 deletions
diff --git a/database/migrations/1503250034279_user.ts b/database/migrations/1503250034279_user.ts index 4a58213..190d47d 100644 --- a/database/migrations/1503250034279_user.ts +++ b/database/migrations/1503250034279_user.ts | |||
@@ -1,20 +1,20 @@ | |||
1 | import { BaseSchema } from '@adonisjs/lucid/schema' | 1 | import { BaseSchema } from '@adonisjs/lucid/schema'; |
2 | 2 | ||
3 | export default class extends BaseSchema { | 3 | export default class extends BaseSchema { |
4 | protected tableName = 'users' | 4 | protected tableName = 'users'; |
5 | 5 | ||
6 | public async up(): Promise<void> { | 6 | public async up(): Promise<void> { |
7 | this.schema.createTable(this.tableName, (table) => { | 7 | this.schema.createTable(this.tableName, table => { |
8 | table.increments() | 8 | table.increments(); |
9 | table.string('username', 80).notNullable() | 9 | table.string('username', 80).notNullable(); |
10 | table.string('email', 254).notNullable().unique() | 10 | table.string('email', 254).notNullable().unique(); |
11 | table.string('password', 60).notNullable() | 11 | table.string('password', 60).notNullable(); |
12 | table.json('settings') | 12 | table.json('settings'); |
13 | table.timestamps() | 13 | table.timestamps(); |
14 | }) | 14 | }); |
15 | } | 15 | } |
16 | 16 | ||
17 | public async down(): Promise<void> { | 17 | public async down(): Promise<void> { |
18 | this.schema.dropTable(this.tableName) | 18 | this.schema.dropTable(this.tableName); |
19 | } | 19 | } |
20 | } | 20 | } |
diff --git a/database/migrations/1503250034280_token.ts b/database/migrations/1503250034280_token.ts index 3830c98..f7b572b 100644 --- a/database/migrations/1503250034280_token.ts +++ b/database/migrations/1503250034280_token.ts | |||
@@ -1,20 +1,20 @@ | |||
1 | import { BaseSchema } from '@adonisjs/lucid/schema' | 1 | import { BaseSchema } from '@adonisjs/lucid/schema'; |
2 | 2 | ||
3 | export default class extends BaseSchema { | 3 | export default class extends BaseSchema { |
4 | protected tableName = 'tokens' | 4 | protected tableName = 'tokens'; |
5 | 5 | ||
6 | public async up(): Promise<void> { | 6 | public async up(): Promise<void> { |
7 | this.schema.createTable(this.tableName, (table) => { | 7 | this.schema.createTable(this.tableName, table => { |
8 | table.increments() | 8 | table.increments(); |
9 | table.integer('user_id').unsigned().references('users.id') | 9 | table.integer('user_id').unsigned().references('users.id'); |
10 | table.string('token', 255).notNullable().unique().index() | 10 | table.string('token', 255).notNullable().unique().index(); |
11 | table.string('type', 80).notNullable() | 11 | table.string('type', 80).notNullable(); |
12 | table.boolean('is_revoked').defaultTo(false) | 12 | table.boolean('is_revoked').defaultTo(false); |
13 | table.timestamps() | 13 | table.timestamps(); |
14 | }) | 14 | }); |
15 | } | 15 | } |
16 | 16 | ||
17 | public async down(): Promise<void> { | 17 | public async down(): Promise<void> { |
18 | this.schema.dropTable(this.tableName) | 18 | this.schema.dropTable(this.tableName); |
19 | } | 19 | } |
20 | } | 20 | } |
diff --git a/database/migrations/1566385379883_service_schema.ts b/database/migrations/1566385379883_service_schema.ts index 3c46cab..cdaff73 100644 --- a/database/migrations/1566385379883_service_schema.ts +++ b/database/migrations/1566385379883_service_schema.ts | |||
@@ -1,21 +1,21 @@ | |||
1 | import { BaseSchema } from '@adonisjs/lucid/schema' | 1 | import { BaseSchema } from '@adonisjs/lucid/schema'; |
2 | 2 | ||
3 | export default class extends BaseSchema { | 3 | export default class extends BaseSchema { |
4 | protected tableName = 'services' | 4 | protected tableName = 'services'; |
5 | 5 | ||
6 | public async up(): Promise<void> { | 6 | public async up(): Promise<void> { |
7 | this.schema.createTable(this.tableName, (table) => { | 7 | this.schema.createTable(this.tableName, table => { |
8 | table.increments() | 8 | table.increments(); |
9 | table.string('userId', 80).notNullable() | 9 | table.string('userId', 80).notNullable(); |
10 | table.string('serviceId', 80).notNullable() | 10 | table.string('serviceId', 80).notNullable(); |
11 | table.string('name', 80).notNullable() | 11 | table.string('name', 80).notNullable(); |
12 | table.string('recipeId', 254).notNullable() | 12 | table.string('recipeId', 254).notNullable(); |
13 | table.json('settings') | 13 | table.json('settings'); |
14 | table.timestamps() | 14 | table.timestamps(); |
15 | }) | 15 | }); |
16 | } | 16 | } |
17 | 17 | ||
18 | public async down(): Promise<void> { | 18 | public async down(): Promise<void> { |
19 | this.schema.dropTable(this.tableName) | 19 | this.schema.dropTable(this.tableName); |
20 | } | 20 | } |
21 | } | 21 | } |
diff --git a/database/migrations/1566554231482_recipe_schema.ts b/database/migrations/1566554231482_recipe_schema.ts index 567c89f..4620be3 100644 --- a/database/migrations/1566554231482_recipe_schema.ts +++ b/database/migrations/1566554231482_recipe_schema.ts | |||
@@ -1,19 +1,19 @@ | |||
1 | import { BaseSchema } from '@adonisjs/lucid/schema' | 1 | import { BaseSchema } from '@adonisjs/lucid/schema'; |
2 | 2 | ||
3 | export default class extends BaseSchema { | 3 | export default class extends BaseSchema { |
4 | protected tableName = 'recipes' | 4 | protected tableName = 'recipes'; |
5 | 5 | ||
6 | public async up(): Promise<void> { | 6 | public async up(): Promise<void> { |
7 | this.schema.createTable(this.tableName, (table) => { | 7 | this.schema.createTable(this.tableName, table => { |
8 | table.increments() | 8 | table.increments(); |
9 | table.string('name', 80).notNullable() | 9 | table.string('name', 80).notNullable(); |
10 | table.string('recipeId', 254).notNullable().unique() | 10 | table.string('recipeId', 254).notNullable().unique(); |
11 | table.json('data') | 11 | table.json('data'); |
12 | table.timestamps() | 12 | table.timestamps(); |
13 | }) | 13 | }); |
14 | } | 14 | } |
15 | 15 | ||
16 | public async down(): Promise<void> { | 16 | public async down(): Promise<void> { |
17 | this.schema.dropTable(this.tableName) | 17 | this.schema.dropTable(this.tableName); |
18 | } | 18 | } |
19 | } | 19 | } |
diff --git a/database/migrations/1566554359294_workspace_schema.ts b/database/migrations/1566554359294_workspace_schema.ts index b863200..32821b3 100644 --- a/database/migrations/1566554359294_workspace_schema.ts +++ b/database/migrations/1566554359294_workspace_schema.ts | |||
@@ -1,22 +1,22 @@ | |||
1 | import { BaseSchema } from '@adonisjs/lucid/schema' | 1 | import { BaseSchema } from '@adonisjs/lucid/schema'; |
2 | 2 | ||
3 | export default class extends BaseSchema { | 3 | export default class extends BaseSchema { |
4 | protected tableName = 'workspaces' | 4 | protected tableName = 'workspaces'; |
5 | 5 | ||
6 | public async up(): Promise<void> { | 6 | public async up(): Promise<void> { |
7 | this.schema.createTable(this.tableName, (table) => { | 7 | this.schema.createTable(this.tableName, table => { |
8 | table.increments() | 8 | table.increments(); |
9 | table.string('workspaceId', 80).notNullable().unique() | 9 | table.string('workspaceId', 80).notNullable().unique(); |
10 | table.string('userId', 80).notNullable() | 10 | table.string('userId', 80).notNullable(); |
11 | table.string('name', 80).notNullable() | 11 | table.string('name', 80).notNullable(); |
12 | table.integer('order') | 12 | table.integer('order'); |
13 | table.json('services') | 13 | table.json('services'); |
14 | table.json('data') | 14 | table.json('data'); |
15 | table.timestamps() | 15 | table.timestamps(); |
16 | }) | 16 | }); |
17 | } | 17 | } |
18 | 18 | ||
19 | public async down(): Promise<void> { | 19 | public async down(): Promise<void> { |
20 | this.schema.dropTable(this.tableName) | 20 | this.schema.dropTable(this.tableName); |
21 | } | 21 | } |
22 | } | 22 | } |
diff --git a/database/migrations/1612629845398_users_update_schema.ts b/database/migrations/1612629845398_users_update_schema.ts index 76dc816..2ee4ee4 100644 --- a/database/migrations/1612629845398_users_update_schema.ts +++ b/database/migrations/1612629845398_users_update_schema.ts | |||
@@ -1,15 +1,15 @@ | |||
1 | import { BaseSchema } from '@adonisjs/lucid/schema' | 1 | import { BaseSchema } from '@adonisjs/lucid/schema'; |
2 | 2 | ||
3 | export default class extends BaseSchema { | 3 | export default class extends BaseSchema { |
4 | public async up(): Promise<void> { | 4 | public async up(): Promise<void> { |
5 | this.schema.alterTable('users', (table) => { | 5 | this.schema.alterTable('users', table => { |
6 | table.string('lastname', 80).notNullable().defaultTo('') | 6 | table.string('lastname', 80).notNullable().defaultTo(''); |
7 | }) | 7 | }); |
8 | } | 8 | } |
9 | 9 | ||
10 | public async down(): Promise<void> { | 10 | public async down(): Promise<void> { |
11 | this.schema.alterTable('users', (table) => { | 11 | this.schema.alterTable('users', table => { |
12 | table.dropColumn('lastname') | 12 | table.dropColumn('lastname'); |
13 | }) | 13 | }); |
14 | } | 14 | } |
15 | } | 15 | } |
diff --git a/database/migrations/1658076326250_correct_token_relations.ts b/database/migrations/1658076326250_correct_token_relations.ts index 1013861..a083c88 100644 --- a/database/migrations/1658076326250_correct_token_relations.ts +++ b/database/migrations/1658076326250_correct_token_relations.ts | |||
@@ -1,16 +1,18 @@ | |||
1 | import { BaseSchema } from '@adonisjs/lucid/schema' | 1 | import { BaseSchema } from '@adonisjs/lucid/schema'; |
2 | 2 | ||
3 | export default class extends BaseSchema { | 3 | export default class extends BaseSchema { |
4 | protected tableName = 'tokens' | 4 | protected tableName = 'tokens'; |
5 | 5 | ||
6 | public async up(): Promise<void> { | 6 | public async up(): Promise<void> { |
7 | await this.db.rawQuery('DELETE FROM tokens WHERE user_id NOT IN (SELECT id FROM users)') | 7 | await this.db.rawQuery( |
8 | 'DELETE FROM tokens WHERE user_id NOT IN (SELECT id FROM users)', | ||
9 | ); | ||
8 | 10 | ||
9 | this.schema.alterTable(this.tableName, (table) => { | 11 | this.schema.alterTable(this.tableName, table => { |
10 | table.dropForeign('user_id') | 12 | table.dropForeign('user_id'); |
11 | 13 | ||
12 | table.foreign('user_id').references('users.id').onDelete('cascade') | 14 | table.foreign('user_id').references('users.id').onDelete('cascade'); |
13 | }) | 15 | }); |
14 | } | 16 | } |
15 | 17 | ||
16 | public async down(): Promise<void> { | 18 | public async down(): Promise<void> { |
diff --git a/database/migrations/1696110557648_jwt_tokens.ts b/database/migrations/1696110557648_jwt_tokens.ts index 7823283..23040e1 100644 --- a/database/migrations/1696110557648_jwt_tokens.ts +++ b/database/migrations/1696110557648_jwt_tokens.ts | |||
@@ -1,23 +1,29 @@ | |||
1 | import { BaseSchema } from '@adonisjs/lucid/schema' | 1 | import { BaseSchema } from '@adonisjs/lucid/schema'; |
2 | 2 | ||
3 | export default class JwtTokens extends BaseSchema { | 3 | export default class JwtTokens extends BaseSchema { |
4 | protected tableName = 'jwt_tokens' | 4 | protected tableName = 'jwt_tokens'; |
5 | 5 | ||
6 | public async up() { | 6 | public async up() { |
7 | this.schema.createTable(this.tableName, (table) => { | 7 | this.schema.createTable(this.tableName, table => { |
8 | table.increments('id').primary() | 8 | table.increments('id').primary(); |
9 | table.integer('user_id').unsigned().references('users.id').onDelete('CASCADE') | 9 | table |
10 | table.string('name').notNullable() | 10 | .integer('user_id') |
11 | table.string('type').notNullable() | 11 | .unsigned() |
12 | table.string('token', 64).notNullable().unique() | 12 | .references('users.id') |
13 | table.timestamp('expires_at', { useTz: true }).nullable() | 13 | .onDelete('CASCADE'); |
14 | table.string('refresh_token').notNullable().unique().index() | 14 | table.string('name').notNullable(); |
15 | table.timestamp('refresh_token_expires_at', { useTz: true }).notNullable() | 15 | table.string('type').notNullable(); |
16 | table.timestamp('created_at', { useTz: true }).notNullable() | 16 | table.string('token', 64).notNullable().unique(); |
17 | }) | 17 | table.timestamp('expires_at', { useTz: true }).nullable(); |
18 | table.string('refresh_token').notNullable().unique().index(); | ||
19 | table | ||
20 | .timestamp('refresh_token_expires_at', { useTz: true }) | ||
21 | .notNullable(); | ||
22 | table.timestamp('created_at', { useTz: true }).notNullable(); | ||
23 | }); | ||
18 | } | 24 | } |
19 | 25 | ||
20 | public async down() { | 26 | public async down() { |
21 | this.schema.dropTable(this.tableName) | 27 | this.schema.dropTable(this.tableName); |
22 | } | 28 | } |
23 | } | 29 | } |