@hedhog/admin 0.0.81 → 0.0.82

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. package/dist/__migrations/migrate-01.d.ts +6 -0
  2. package/dist/__migrations/migrate-01.d.ts.map +1 -0
  3. package/dist/__migrations/migrate-01.js +80 -0
  4. package/dist/__migrations/migrate-01.js.map +1 -0
  5. package/dist/__migrations/migrate-02.d.ts +6 -0
  6. package/dist/__migrations/migrate-02.d.ts.map +1 -0
  7. package/dist/__migrations/migrate-02.js +68 -0
  8. package/dist/__migrations/migrate-02.js.map +1 -0
  9. package/dist/__migrations/migrate-03.d.ts +6 -0
  10. package/dist/__migrations/migrate-03.d.ts.map +1 -0
  11. package/dist/__migrations/migrate-03.js +90 -0
  12. package/dist/__migrations/migrate-03.js.map +1 -0
  13. package/dist/__migrations/migrate-04.d.ts +6 -0
  14. package/dist/__migrations/migrate-04.d.ts.map +1 -0
  15. package/dist/__migrations/migrate-04.js +63 -0
  16. package/dist/__migrations/migrate-04.js.map +1 -0
  17. package/dist/__migrations/migrate-05.d.ts +6 -0
  18. package/dist/__migrations/migrate-05.d.ts.map +1 -0
  19. package/dist/__migrations/migrate-05.js +100 -0
  20. package/dist/__migrations/migrate-05.js.map +1 -0
  21. package/dist/__migrations/migrate-06.d.ts +6 -0
  22. package/dist/__migrations/migrate-06.d.ts.map +1 -0
  23. package/dist/__migrations/migrate-06.js +37 -0
  24. package/dist/__migrations/migrate-06.js.map +1 -0
  25. package/dist/__migrations/migrate-07.d.ts +6 -0
  26. package/dist/__migrations/migrate-07.d.ts.map +1 -0
  27. package/dist/__migrations/migrate-07.js +59 -0
  28. package/dist/__migrations/migrate-07.js.map +1 -0
  29. package/dist/__migrations/migrate-08.d.ts +6 -0
  30. package/dist/__migrations/migrate-08.d.ts.map +1 -0
  31. package/dist/__migrations/migrate-08.js +39 -0
  32. package/dist/__migrations/migrate-08.js.map +1 -0
  33. package/dist/__migrations/migrate-09.d.ts +6 -0
  34. package/dist/__migrations/migrate-09.d.ts.map +1 -0
  35. package/dist/__migrations/migrate-09.js +39 -0
  36. package/dist/__migrations/migrate-09.js.map +1 -0
  37. package/dist/__migrations/migrate-10.d.ts +6 -0
  38. package/dist/__migrations/migrate-10.d.ts.map +1 -0
  39. package/dist/__migrations/migrate-10.js +39 -0
  40. package/dist/__migrations/migrate-10.js.map +1 -0
  41. package/dist/__migrations/migrate-11.d.ts +6 -0
  42. package/dist/__migrations/migrate-11.d.ts.map +1 -0
  43. package/dist/__migrations/migrate-11.js +39 -0
  44. package/dist/__migrations/migrate-11.js.map +1 -0
  45. package/dist/__migrations/migrate-12.d.ts +6 -0
  46. package/dist/__migrations/migrate-12.d.ts.map +1 -0
  47. package/dist/__migrations/migrate-12.js +39 -0
  48. package/dist/__migrations/migrate-12.js.map +1 -0
  49. package/dist/__migrations/migrate-13.d.ts +6 -0
  50. package/dist/__migrations/migrate-13.d.ts.map +1 -0
  51. package/dist/__migrations/migrate-13.js +30 -0
  52. package/dist/__migrations/migrate-13.js.map +1 -0
  53. package/dist/__migrations/migrate-14.d.ts +6 -0
  54. package/dist/__migrations/migrate-14.d.ts.map +1 -0
  55. package/dist/__migrations/migrate-14.js +83 -0
  56. package/dist/__migrations/migrate-14.js.map +1 -0
  57. package/dist/__migrations/migrate-15.d.ts +6 -0
  58. package/dist/__migrations/migrate-15.d.ts.map +1 -0
  59. package/dist/__migrations/migrate-15.js +25 -0
  60. package/dist/__migrations/migrate-15.js.map +1 -0
  61. package/dist/__migrations/migrate-16.d.ts +6 -0
  62. package/dist/__migrations/migrate-16.d.ts.map +1 -0
  63. package/dist/__migrations/migrate-16.js +61 -0
  64. package/dist/__migrations/migrate-16.js.map +1 -0
  65. package/dist/__migrations/migrate-17.d.ts +6 -0
  66. package/dist/__migrations/migrate-17.d.ts.map +1 -0
  67. package/dist/__migrations/migrate-17.js +31 -0
  68. package/dist/__migrations/migrate-17.js.map +1 -0
  69. package/dist/__migrations/migrate-18.d.ts +6 -0
  70. package/dist/__migrations/migrate-18.d.ts.map +1 -0
  71. package/dist/__migrations/migrate-18.js +41 -0
  72. package/dist/__migrations/migrate-18.js.map +1 -0
  73. package/dist/__migrations/migrate-19.d.ts +6 -0
  74. package/dist/__migrations/migrate-19.d.ts.map +1 -0
  75. package/dist/__migrations/migrate-19.js +175 -0
  76. package/dist/__migrations/migrate-19.js.map +1 -0
  77. package/dist/__migrations/migrate-20.d.ts +6 -0
  78. package/dist/__migrations/migrate-20.d.ts.map +1 -0
  79. package/dist/__migrations/migrate-20.js +310 -0
  80. package/dist/__migrations/migrate-20.js.map +1 -0
  81. package/hedhog.yaml +487 -0
  82. package/package.json +1 -1
  83. package/src/migrations/migrate-01.ts +0 -86
  84. package/src/migrations/migrate-02.ts +0 -77
  85. package/src/migrations/migrate-03.ts +0 -102
  86. package/src/migrations/migrate-04.ts +0 -71
  87. package/src/migrations/migrate-05.ts +0 -119
  88. package/src/migrations/migrate-06.ts +0 -37
  89. package/src/migrations/migrate-07.ts +0 -66
  90. package/src/migrations/migrate-08.ts +0 -44
  91. package/src/migrations/migrate-09.ts +0 -44
  92. package/src/migrations/migrate-10.ts +0 -44
  93. package/src/migrations/migrate-11.ts +0 -45
  94. package/src/migrations/migrate-12.ts +0 -44
  95. package/src/migrations/migrate-13.ts +0 -28
  96. package/src/migrations/migrate-14.ts +0 -81
  97. package/src/migrations/migrate-15.ts +0 -23
  98. package/src/migrations/migrate-16.ts +0 -59
  99. package/src/migrations/migrate-17.ts +0 -29
  100. package/src/migrations/migrate-18.ts +0 -39
  101. package/src/migrations/migrate-19.ts +0 -186
  102. package/src/migrations/migrate-20.ts +0 -308
@@ -1,102 +0,0 @@
1
- import {
2
- MigrationInterface,
3
- QueryRunner,
4
- Table,
5
- TableForeignKey,
6
- } from 'typeorm';
7
- import { foreignColumn, idColumn, timestampColumn } from '@hedhog/utils';
8
-
9
- export class Migrate implements MigrationInterface {
10
- async up(queryRunner: QueryRunner) {
11
- await queryRunner.createTable(
12
- new Table({
13
- name: 'multifactors',
14
- columns: [
15
- idColumn(),
16
- {
17
- name: 'slug',
18
- type: 'varchar',
19
- isUnique: true,
20
- },
21
- timestampColumn(),
22
- timestampColumn('updated_at'),
23
- ],
24
- }),
25
- true,
26
- );
27
-
28
- await queryRunner.createTable(
29
- new Table({
30
- name: 'multifactor_translations',
31
- columns: [
32
- foreignColumn({ name: 'multifactor_id', isPrimary: true }),
33
- foreignColumn({ name: 'locale_id', isPrimary: true }),
34
- {
35
- name: 'name',
36
- type: 'varchar',
37
- },
38
- timestampColumn(),
39
- timestampColumn('updated_at'),
40
- ],
41
- foreignKeys: [
42
- new TableForeignKey({
43
- columnNames: ['multifactor_id'],
44
- referencedTableName: 'multifactors',
45
- referencedColumnNames: ['id'],
46
- onDelete: 'CASCADE',
47
- }),
48
- new TableForeignKey({
49
- columnNames: ['locale_id'],
50
- referencedTableName: 'locales',
51
- referencedColumnNames: ['id'],
52
- onDelete: 'CASCADE',
53
- }),
54
- ],
55
- }),
56
- true,
57
- );
58
-
59
- await queryRunner.createTable(
60
- new Table({
61
- name: 'users',
62
- columns: [
63
- idColumn(),
64
- foreignColumn({ name: 'multifactor_id', isNullable: true }),
65
- {
66
- name: 'name',
67
- type: 'varchar',
68
- },
69
- {
70
- name: 'email',
71
- type: 'varchar',
72
- },
73
- {
74
- name: 'password',
75
- type: 'varchar',
76
- },
77
- {
78
- name: 'code',
79
- type: 'varchar',
80
- isNullable: true,
81
- },
82
- timestampColumn(),
83
- timestampColumn('updated_at'),
84
- ],
85
- }),
86
- );
87
-
88
- await queryRunner.createForeignKeys('users', [
89
- new TableForeignKey({
90
- columnNames: ['multifactor_id'],
91
- referencedColumnNames: ['id'],
92
- referencedTableName: 'multifactors',
93
- name: 'fk_users_to_multifactors_on_multifactor_id',
94
- onDelete: 'Cascade',
95
- }),
96
- ]);
97
- }
98
- async down(queryRunner: QueryRunner) {
99
- await queryRunner.dropTable('multifactors');
100
- await queryRunner.dropTable('users');
101
- }
102
- }
@@ -1,71 +0,0 @@
1
- import { foreignColumn, idColumn, timestampColumn } from '@hedhog/utils';
2
-
3
- import {
4
- MigrationInterface,
5
- QueryRunner,
6
- Table,
7
- TableForeignKey,
8
- } from 'typeorm';
9
-
10
- export class Migrate implements MigrationInterface {
11
- async up(queryRunner: QueryRunner) {
12
- await queryRunner.createTable(
13
- new Table({
14
- name: 'screens',
15
- columns: [
16
- idColumn(),
17
- {
18
- name: 'slug',
19
- type: 'varchar',
20
- isUnique: true,
21
- },
22
- {
23
- name: 'icon',
24
- type: 'varchar',
25
- isNullable: true,
26
- },
27
- timestampColumn(),
28
- timestampColumn('updated_at'),
29
- ],
30
- }),
31
- );
32
-
33
- await queryRunner.createTable(
34
- new Table({
35
- name: 'screen_translations',
36
- columns: [
37
- foreignColumn({ name: 'screen_id', isPrimary: true }),
38
- foreignColumn({ name: 'locale_id', isPrimary: true }),
39
- {
40
- name: 'name',
41
- type: 'varchar',
42
- },
43
- {
44
- name: 'description',
45
- type: 'varchar',
46
- },
47
- timestampColumn(),
48
- timestampColumn('updated_at'),
49
- ],
50
- foreignKeys: [
51
- new TableForeignKey({
52
- columnNames: ['screen_id'],
53
- referencedTableName: 'screens',
54
- referencedColumnNames: ['id'],
55
- onDelete: 'CASCADE',
56
- }),
57
- new TableForeignKey({
58
- columnNames: ['locale_id'],
59
- referencedTableName: 'locales',
60
- referencedColumnNames: ['id'],
61
- onDelete: 'CASCADE',
62
- }),
63
- ],
64
- }),
65
- );
66
- }
67
-
68
- async down(queryRunner: QueryRunner) {
69
- await queryRunner.dropTable('screens');
70
- }
71
- }
@@ -1,119 +0,0 @@
1
- import {
2
- MigrationInterface,
3
- QueryRunner,
4
- Table,
5
- TableForeignKey,
6
- } from 'typeorm';
7
- import { foreignColumn, idColumn, timestampColumn } from '@hedhog/utils';
8
- import { Menu } from '../entities';
9
-
10
- export class Migrate implements MigrationInterface {
11
- public async up(queryRunner: QueryRunner): Promise<void> {
12
- await queryRunner.createTable(
13
- new Table({
14
- name: 'menus',
15
- columns: [
16
- idColumn(),
17
- foreignColumn({ name: 'menu_id', isNullable: true }),
18
- {
19
- name: 'slug',
20
- type: 'varchar',
21
- isUnique: true,
22
- },
23
- {
24
- name: 'url',
25
- type: 'varchar',
26
- isNullable: true,
27
- },
28
- {
29
- name: 'order',
30
- type: 'int',
31
- default: 0,
32
- unsigned: true,
33
- },
34
- {
35
- name: 'icon',
36
- type: 'varchar',
37
- isNullable: true,
38
- },
39
- timestampColumn(),
40
- timestampColumn('updated_at'),
41
- ],
42
- indices: [{ columnNames: ['slug'], isUnique: true }],
43
- foreignKeys: [
44
- {
45
- columnNames: ['menu_id'],
46
- referencedColumnNames: ['id'],
47
- referencedTableName: 'menus',
48
- onDelete: 'CASCADE',
49
- },
50
- ],
51
- }),
52
- );
53
-
54
- await queryRunner.createTable(
55
- new Table({
56
- name: 'menu_translations',
57
- columns: [
58
- foreignColumn({ name: 'menu_id', isPrimary: true }),
59
- foreignColumn({ name: 'locale_id', isPrimary: true }),
60
- {
61
- name: 'name',
62
- type: 'varchar',
63
- },
64
- timestampColumn(),
65
- timestampColumn('updated_at'),
66
- ],
67
- foreignKeys: [
68
- new TableForeignKey({
69
- columnNames: ['menu_id'],
70
- referencedColumnNames: ['id'],
71
- referencedTableName: 'menus',
72
- onDelete: 'CASCADE',
73
- }),
74
- new TableForeignKey({
75
- columnNames: ['locale_id'],
76
- referencedColumnNames: ['id'],
77
- referencedTableName: 'locales',
78
- onDelete: 'CASCADE',
79
- }),
80
- ],
81
- }),
82
- );
83
-
84
- await queryRunner.createTable(
85
- new Table({
86
- name: 'menu_screens',
87
- columns: [
88
- foreignColumn({ name: 'menu_id', isPrimary: true }),
89
- foreignColumn({ name: 'screen_id', isPrimary: true }),
90
- ],
91
- }),
92
- );
93
-
94
- await queryRunner.createForeignKey(
95
- 'menu_screens',
96
- new TableForeignKey({
97
- columnNames: ['menu_id'],
98
- referencedColumnNames: ['id'],
99
- referencedTableName: 'menus',
100
- onDelete: 'CASCADE',
101
- }),
102
- );
103
-
104
- await queryRunner.createForeignKey(
105
- 'menu_screens',
106
- new TableForeignKey({
107
- columnNames: ['screen_id'],
108
- referencedColumnNames: ['id'],
109
- referencedTableName: 'screens',
110
- onDelete: 'CASCADE',
111
- }),
112
- );
113
- }
114
-
115
- public async down(queryRunner: QueryRunner): Promise<void> {
116
- await queryRunner.dropTable('menu_screens');
117
- await queryRunner.dropTable('menus');
118
- }
119
- }
@@ -1,37 +0,0 @@
1
- import { idColumn, timestampColumn } from '@hedhog/utils';
2
-
3
- import { MigrationInterface, QueryRunner, Table, TableUnique } from 'typeorm';
4
- import { Menu } from '../entities';
5
-
6
- export class Migrate implements MigrationInterface {
7
- async up(queryRunner: QueryRunner) {
8
- await queryRunner.createTable(
9
- new Table({
10
- name: 'routes',
11
- columns: [
12
- idColumn(),
13
- {
14
- name: 'url',
15
- type: 'varchar',
16
- },
17
- {
18
- name: 'method',
19
- type: 'enum',
20
- enum: ['GET', 'POST', 'PATCH', 'DELETE', 'PUT', 'OPTIONS', 'HEAD'],
21
- },
22
- timestampColumn(),
23
- timestampColumn('updated_at'),
24
- ],
25
- indices: [
26
- {
27
- columnNames: ['url', 'method'],
28
- isUnique: true,
29
- },
30
- ],
31
- }),
32
- );
33
- }
34
- async down(queryRunner: QueryRunner) {
35
- await queryRunner.dropTable('routes');
36
- }
37
- }
@@ -1,66 +0,0 @@
1
- import { foreignColumn, idColumn, timestampColumn } from '@hedhog/utils';
2
- import {
3
- MigrationInterface,
4
- QueryRunner,
5
- Table,
6
- TableForeignKey,
7
- } from 'typeorm';
8
-
9
- export class Migrate implements MigrationInterface {
10
- async up(queryRunner: QueryRunner) {
11
- await queryRunner.createTable(
12
- new Table({
13
- name: 'roles',
14
- columns: [
15
- idColumn(),
16
- {
17
- name: 'slug',
18
- type: 'varchar',
19
- isUnique: true,
20
- },
21
- timestampColumn(),
22
- timestampColumn('updated_at'),
23
- ],
24
- }),
25
- );
26
-
27
- await queryRunner.createTable(
28
- new Table({
29
- name: 'role_translations',
30
- columns: [
31
- foreignColumn({ name: 'role_id', isPrimary: true }),
32
- foreignColumn({ name: 'locale_id', isPrimary: true }),
33
- {
34
- name: 'name',
35
- type: 'varchar',
36
- isNullable: false,
37
- },
38
- {
39
- name: 'description',
40
- type: 'varchar',
41
- },
42
- timestampColumn(),
43
- timestampColumn('updated_at'),
44
- ],
45
- foreignKeys: [
46
- new TableForeignKey({
47
- columnNames: ['role_id'],
48
- referencedTableName: 'roles',
49
- referencedColumnNames: ['id'],
50
- onDelete: 'CASCADE',
51
- }),
52
- new TableForeignKey({
53
- columnNames: ['locale_id'],
54
- referencedTableName: 'locales',
55
- referencedColumnNames: ['id'],
56
- onDelete: 'CASCADE',
57
- }),
58
- ],
59
- }),
60
- );
61
- }
62
-
63
- async down(queryRunner: QueryRunner) {
64
- await queryRunner.dropTable('roles');
65
- }
66
- }
@@ -1,44 +0,0 @@
1
- import { foreignColumn, timestampColumn } from '@hedhog/utils';
2
- import {
3
- MigrationInterface,
4
- QueryRunner,
5
- Table,
6
- TableForeignKey,
7
- } from 'typeorm';
8
-
9
- export class Migrate implements MigrationInterface {
10
- async up(queryRunner: QueryRunner) {
11
- await queryRunner.createTable(
12
- new Table({
13
- name: 'role_menus',
14
- columns: [
15
- foreignColumn({ name: 'role_id', isPrimary: true }),
16
- foreignColumn({ name: 'menu_id', isPrimary: true }),
17
- timestampColumn(),
18
- timestampColumn('updated_at'),
19
- ],
20
- }),
21
- );
22
-
23
- await queryRunner.createForeignKeys('role_menus', [
24
- new TableForeignKey({
25
- columnNames: ['role_id'],
26
- referencedColumnNames: ['id'],
27
- referencedTableName: 'roles',
28
- onDelete: 'CASCADE',
29
- name: 'fk_role_menus_roles',
30
- }),
31
- new TableForeignKey({
32
- columnNames: ['menu_id'],
33
- referencedColumnNames: ['id'],
34
- referencedTableName: 'menus',
35
- onDelete: 'CASCADE',
36
- name: 'fk_role_menus_menus',
37
- }),
38
- ]);
39
- }
40
-
41
- async down(queryRunner: QueryRunner) {
42
- await queryRunner.dropTable('role_menus');
43
- }
44
- }
@@ -1,44 +0,0 @@
1
- import { foreignColumn, timestampColumn } from '@hedhog/utils';
2
- import {
3
- MigrationInterface,
4
- QueryRunner,
5
- Table,
6
- TableForeignKey,
7
- } from 'typeorm';
8
-
9
- export class Migrate implements MigrationInterface {
10
- async up(queryRunner: QueryRunner) {
11
- await queryRunner.createTable(
12
- new Table({
13
- name: 'route_screens',
14
- columns: [
15
- foreignColumn({ name: 'route_id', isPrimary: true }),
16
- foreignColumn({ name: 'screen_id', isPrimary: true }),
17
- timestampColumn(),
18
- timestampColumn('updated_at'),
19
- ],
20
- }),
21
- );
22
-
23
- await queryRunner.createForeignKeys('route_screens', [
24
- new TableForeignKey({
25
- columnNames: ['route_id'],
26
- referencedColumnNames: ['id'],
27
- referencedTableName: 'routes',
28
- onDelete: 'CASCADE',
29
- name: 'fk_route_screens_routes',
30
- }),
31
- new TableForeignKey({
32
- columnNames: ['screen_id'],
33
- referencedColumnNames: ['id'],
34
- referencedTableName: 'screens',
35
- onDelete: 'CASCADE',
36
- name: 'fk_route_screens_screens',
37
- }),
38
- ]);
39
- }
40
-
41
- async down(queryRunner: QueryRunner) {
42
- await queryRunner.dropTable('route_screens');
43
- }
44
- }
@@ -1,44 +0,0 @@
1
- import { foreignColumn, timestampColumn } from '@hedhog/utils';
2
- import {
3
- MigrationInterface,
4
- QueryRunner,
5
- Table,
6
- TableForeignKey,
7
- } from 'typeorm';
8
-
9
- export class Migrate implements MigrationInterface {
10
- async up(queryRunner: QueryRunner) {
11
- await queryRunner.createTable(
12
- new Table({
13
- name: 'role_screens',
14
- columns: [
15
- foreignColumn({ name: 'role_id', isPrimary: true }),
16
- foreignColumn({ name: 'screen_id', isPrimary: true }),
17
- timestampColumn(),
18
- timestampColumn('updated_at'),
19
- ],
20
- }),
21
- );
22
-
23
- await queryRunner.createForeignKeys('role_screens', [
24
- new TableForeignKey({
25
- columnNames: ['role_id'],
26
- referencedColumnNames: ['id'],
27
- referencedTableName: 'roles',
28
- onDelete: 'CASCADE',
29
- name: 'fk_role_screens_roles',
30
- }),
31
- new TableForeignKey({
32
- columnNames: ['screen_id'],
33
- referencedColumnNames: ['id'],
34
- referencedTableName: 'screens',
35
- onDelete: 'CASCADE',
36
- name: 'fk_role_screens_screens',
37
- }),
38
- ]);
39
- }
40
-
41
- async down(queryRunner: QueryRunner) {
42
- await queryRunner.dropTable('role_screens');
43
- }
44
- }
@@ -1,45 +0,0 @@
1
- import { foreignColumn, timestampColumn } from '@hedhog/utils';
2
- import {
3
- MigrationInterface,
4
- QueryRunner,
5
- Table,
6
- TableForeignKey,
7
- } from 'typeorm';
8
-
9
- export class Migrate implements MigrationInterface {
10
- async up(queryRunner: QueryRunner) {
11
- await queryRunner.createTable(
12
- new Table({
13
- name: 'role_users',
14
- columns: [
15
- foreignColumn({ name: 'role_id', isPrimary: true }),
16
- foreignColumn({ name: 'user_id', isPrimary: true }),
17
- timestampColumn(),
18
- timestampColumn('updated_at'),
19
- ],
20
- }),
21
- );
22
-
23
- await queryRunner.createForeignKeys('role_users', [
24
- new TableForeignKey({
25
- columnNames: ['role_id'],
26
- referencedColumnNames: ['id'],
27
- referencedTableName: 'roles',
28
- onDelete: 'CASCADE',
29
- name: 'fk_role_users_roles',
30
- }),
31
-
32
- new TableForeignKey({
33
- columnNames: ['user_id'],
34
- referencedColumnNames: ['id'],
35
- referencedTableName: 'users',
36
- onDelete: 'CASCADE',
37
- name: 'fk_role_users_users',
38
- }),
39
- ]);
40
- }
41
-
42
- async down(queryRunner: QueryRunner) {
43
- await queryRunner.dropTable('role_users');
44
- }
45
- }
@@ -1,44 +0,0 @@
1
- import { foreignColumn, timestampColumn } from '@hedhog/utils';
2
- import {
3
- MigrationInterface,
4
- QueryRunner,
5
- Table,
6
- TableForeignKey,
7
- } from 'typeorm';
8
-
9
- export class Migrate implements MigrationInterface {
10
- async up(queryRunner: QueryRunner) {
11
- await queryRunner.createTable(
12
- new Table({
13
- name: 'role_routes',
14
- columns: [
15
- foreignColumn({ name: 'role_id', isPrimary: true }),
16
- foreignColumn({ name: 'route_id', isPrimary: true }),
17
- timestampColumn(),
18
- timestampColumn('updated_at'),
19
- ],
20
- }),
21
- );
22
-
23
- await queryRunner.createForeignKeys('role_routes', [
24
- new TableForeignKey({
25
- columnNames: ['role_id'],
26
- referencedColumnNames: ['id'],
27
- referencedTableName: 'roles',
28
- onDelete: 'CASCADE',
29
- name: 'fk_role_routes_roles',
30
- }),
31
- new TableForeignKey({
32
- columnNames: ['route_id'],
33
- referencedColumnNames: ['id'],
34
- referencedTableName: 'routes',
35
- onDelete: 'CASCADE',
36
- name: 'fk_role_routes_routes',
37
- }),
38
- ]);
39
- }
40
-
41
- async down(queryRunner: QueryRunner) {
42
- await queryRunner.dropTable('role_routes');
43
- }
44
- }
@@ -1,28 +0,0 @@
1
- import { MigrationInterface, QueryRunner } from 'typeorm';
2
-
3
- export class Migrate implements MigrationInterface {
4
- async up(queryRunner: QueryRunner) {
5
- /*
6
- const menus = await queryRunner.manager
7
- .createQueryBuilder()
8
- .select()
9
- .from('menus', 'm')
10
- .execute();
11
-
12
- for (const menu of menus) {
13
- await queryRunner.manager
14
- .createQueryBuilder()
15
- .insert()
16
- .into('role_menus')
17
- .values({
18
- role_id: 1,
19
- menu_id: menu.id,
20
- });
21
- }
22
- */
23
- }
24
-
25
- async down(queryRunner: QueryRunner) {
26
- await queryRunner.manager.delete('role_menus', { role_id: 1 });
27
- }
28
- }