diff options
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, 85 insertions, 93 deletions
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 @@ | |||
1 | import BaseSchema from '@ioc:Adonis/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 5a030d0..3830c98 100644 --- a/database/migrations/1503250034280_token.ts +++ b/database/migrations/1503250034280_token.ts | |||
@@ -1,20 +1,20 @@ | |||
1 | import BaseSchema from '@ioc:Adonis/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 9c3e23d..3c46cab 100644 --- a/database/migrations/1566385379883_service_schema.ts +++ b/database/migrations/1566385379883_service_schema.ts | |||
@@ -1,21 +1,21 @@ | |||
1 | import BaseSchema from '@ioc:Adonis/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 3a9784d..567c89f 100644 --- a/database/migrations/1566554231482_recipe_schema.ts +++ b/database/migrations/1566554231482_recipe_schema.ts | |||
@@ -1,19 +1,19 @@ | |||
1 | import BaseSchema from '@ioc:Adonis/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 77e1189..b863200 100644 --- a/database/migrations/1566554359294_workspace_schema.ts +++ b/database/migrations/1566554359294_workspace_schema.ts | |||
@@ -1,22 +1,22 @@ | |||
1 | import BaseSchema from '@ioc:Adonis/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 8831ea4..76dc816 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 '@ioc:Adonis/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 5486657..1013861 100644 --- a/database/migrations/1658076326250_correct_token_relations.ts +++ b/database/migrations/1658076326250_correct_token_relations.ts | |||
@@ -1,18 +1,16 @@ | |||
1 | import BaseSchema from '@ioc:Adonis/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( | 7 | await this.db.rawQuery('DELETE FROM tokens WHERE user_id NOT IN (SELECT id FROM users)') |
8 | 'DELETE FROM tokens WHERE user_id NOT IN (SELECT id FROM users)', | ||
9 | ); | ||
10 | 8 | ||
11 | this.schema.alterTable(this.tableName, table => { | 9 | this.schema.alterTable(this.tableName, (table) => { |
12 | table.dropForeign('user_id'); | 10 | table.dropForeign('user_id') |
13 | 11 | ||
14 | table.foreign('user_id').references('users.id').onDelete('cascade'); | 12 | table.foreign('user_id').references('users.id').onDelete('cascade') |
15 | }); | 13 | }) |
16 | } | 14 | } |
17 | 15 | ||
18 | public async down(): Promise<void> { | 16 | public async down(): Promise<void> { |
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 @@ | |||
1 | import BaseSchema from '@ioc:Adonis/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 | 9 | table.integer('user_id').unsigned().references('users.id').onDelete('CASCADE') |
10 | .integer('user_id') | 10 | table.string('name').notNullable() |
11 | .unsigned() | 11 | table.string('type').notNullable() |
12 | .references('users.id') | 12 | table.string('token', 64).notNullable().unique() |
13 | .onDelete('CASCADE'); | 13 | table.timestamp('expires_at', { useTz: true }).nullable() |
14 | table.string('name').notNullable(); | 14 | table.string('refresh_token').notNullable().unique().index() |
15 | table.string('type').notNullable(); | 15 | table.timestamp('refresh_token_expires_at', { useTz: true }).notNullable() |
16 | table.string('token', 64).notNullable().unique(); | 16 | table.timestamp('created_at', { useTz: true }).notNullable() |
17 | table.timestamp('expires_at', { useTz: true }).nullable(); | 17 | }) |
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 | }); | ||
24 | } | 18 | } |
25 | 19 | ||
26 | public async down() { | 20 | public async down() { |
27 | this.schema.dropTable(this.tableName); | 21 | this.schema.dropTable(this.tableName) |
28 | } | 22 | } |
29 | } | 23 | } |