Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit e34aa93

Browse filesBrowse files
committed
Lang schema created to tables that use translation
1 parent d869d91 commit e34aa93
Copy full SHA for e34aa93

10 files changed

+21
-19
lines changed

‎src/db/entities/Lang.ts

Copy file name to clipboardExpand all lines: src/db/entities/Lang.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
import BaseEntity from './BaseEntity';
77

88
@ObjectType()
9-
@Entity({ name: 'lang' })
9+
@Entity({ name: 'lang', schema: 'lang' })
1010
class Lang extends BaseEntity {
1111
@Field(() => String)
1212
@PrimaryColumn()

‎src/db/entities/Text.ts

Copy file name to clipboardExpand all lines: src/db/entities/Text.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
import BaseEntity from './BaseEntity';
77

88
@ObjectType()
9-
@Entity({ name: 'text' })
9+
@Entity({ name: 'text', schema: 'lang' })
1010
export default class Text extends BaseEntity {
1111
@Field(() => String)
1212
@Column()

‎src/db/entities/Translation.ts

Copy file name to clipboardExpand all lines: src/db/entities/Translation.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import BaseEntity from './BaseEntity';
99
import VText from './VText';
1010

1111
@ObjectType()
12-
@Entity({ name: 'translation' })
12+
@Entity({ name: 'translation', schema: 'lang' })
1313
export default class Translation extends BaseEntity {
1414
@Field(() => Int)
1515
@PrimaryGeneratedColumn()

‎src/db/entities/VText.ts

Copy file name to clipboardExpand all lines: src/db/entities/VText.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {
44
} from 'typeorm';
55

66
@ObjectType()
7-
@ViewEntity({ name: 'vtext' })
7+
@ViewEntity({ name: 'vtext', schema: 'lang' })
88
export default class VText extends BaseEntity {
99
@Field(() => String)
1010
@ViewColumn()

‎src/db/migrations/1601324673082-Lang.ts

Copy file name to clipboardExpand all lines: src/db/migrations/1601324673082-Lang.ts
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@ import columns from './BaseTableColumns/columns';
44
import Lang from '../entities/Lang';
55

66
export default class Lang1601324673082 implements MigrationInterface {
7-
private readonly tableName = 'lang';
7+
private readonly tableName = 'lang.lang';
88

99
public async up(queryRunner: QueryRunner): Promise<void> {
10+
await queryRunner.manager.query('CREATE SCHEMA IF NOT EXISTS lang;');
1011
await queryRunner.createTable(new Table({
1112
name: this.tableName,
1213
columns: [
@@ -59,6 +60,7 @@ export default class Lang1601324673082 implements MigrationInterface {
5960

6061
public async down(queryRunner: QueryRunner): Promise<void> {
6162
queryRunner.manager.query('DROP EXTENSION IF EXISTS unaccent;');
63+
queryRunner.manager.query('DROP SCHEMA IF EXISTS lang;');
6264
await queryRunner.dropTable(this.tableName);
6365
}
6466
}

‎src/db/migrations/1601324673092-Translation.ts

Copy file name to clipboardExpand all lines: src/db/migrations/1601324673092-Translation.ts
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { MigrationInterface, QueryRunner, Table } from 'typeorm';
33
import columns from './BaseTableColumns/columns';
44

55
export default class Translation1601324673092 implements MigrationInterface {
6-
private readonly tableName = 'translation';
6+
private readonly tableName = 'lang.translation';
77

88
public async up(queryRunner: QueryRunner): Promise<void> {
99
await queryRunner.createTable(new Table({

‎src/db/migrations/1601324673095-Text.ts

Copy file name to clipboardExpand all lines: src/db/migrations/1601324673095-Text.ts
+3-3Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
import columns from './BaseTableColumns/columns';
66

77
export default class Text1601324673095 implements MigrationInterface {
8-
private readonly tableName = 'text';
8+
private readonly tableName = 'lang.text';
99

1010
public async up(queryRunner: QueryRunner): Promise<void> {
1111
await queryRunner.createTable(new Table({
@@ -31,15 +31,15 @@ export default class Text1601324673095 implements MigrationInterface {
3131
name: 'text_translation',
3232
columnNames: ['translation_id'],
3333
referencedColumnNames: ['id'],
34-
referencedTableName: 'translation',
34+
referencedTableName: 'lang.translation',
3535
onDelete: 'CASCADE',
3636
}));
3737

3838
await queryRunner.createForeignKey(this.tableName, new TableForeignKey({
3939
name: 'text_lang',
4040
columnNames: ['lang_id'],
4141
referencedColumnNames: ['id'],
42-
referencedTableName: 'lang',
42+
referencedTableName: 'lang.lang',
4343
onDelete: 'CASCADE',
4444
}));
4545

‎src/db/migrations/1601324674382-UserStatus.ts

Copy file name to clipboardExpand all lines: src/db/migrations/1601324674382-UserStatus.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ export default class UserStatus1601324674982 implements MigrationInterface {
4242
name: 'user_status_name_translation',
4343
columnNames: ['name_id'],
4444
referencedColumnNames: ['id'],
45-
referencedTableName: 'translation',
45+
referencedTableName: 'lang.translation',
4646
onDelete: 'RESTRICT',
4747
}));
4848

4949
await queryRunner.createForeignKey(this.tableName, new TableForeignKey({
5050
name: 'user_status_description_translation',
5151
columnNames: ['description_id'],
5252
referencedColumnNames: ['id'],
53-
referencedTableName: 'translation',
53+
referencedTableName: 'lang.translation',
5454
onDelete: 'RESTRICT',
5555
}));
5656
await this.addDefaultValues(queryRunner);

‎src/db/migrations/1601324674992-Role.ts

Copy file name to clipboardExpand all lines: src/db/migrations/1601324674992-Role.ts
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ export default class Role1601324674992 implements MigrationInterface {
3737
name: 'role_name',
3838
columnNames: ['name_id'],
3939
referencedColumnNames: ['id'],
40-
referencedTableName: 'translation',
40+
referencedTableName: 'lang.translation',
4141
onDelete: 'RESTRICT',
4242
}));
4343

4444
await queryRunner.createForeignKey(this.tableName, new TableForeignKey({
4545
name: 'role_description_translation',
4646
columnNames: ['description_id'],
4747
referencedColumnNames: ['id'],
48-
referencedTableName: 'translation',
48+
referencedTableName: 'lang.translation',
4949
onDelete: 'RESTRICT',
5050
}));
5151

‎src/db/migrations/1601738944127-VText.ts

Copy file name to clipboardExpand all lines: src/db/migrations/1601738944127-VText.ts
+6-6Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ import {
33
} from 'typeorm';
44

55
export default class VText1601738944127 implements MigrationInterface {
6-
private readonly viewName = 'text';
6+
private readonly viewName = 'lang.vtext';
77

88
public async up(queryRunner: QueryRunner): Promise<void> {
99
const view = `
10-
CREATE VIEW vtext AS SELECT
10+
CREATE VIEW ${this.viewName} AS SELECT
1111
CONCAT(lang.id, '-', translation.id) as id,
1212
translation.id as translation_id,
1313
translation.is_blocked,
@@ -44,12 +44,12 @@ export default class VText1601738944127 implements MigrationInterface {
4444
WHEN originalText.updated_by IS NOT NULL THEN originalText.updated_by
4545
ELSE text.updated_by
4646
END AS updated_by
47-
FROM translation
48-
CROSS JOIN lang
49-
LEFT JOIN text text
47+
FROM lang.translation
48+
CROSS JOIN lang.lang
49+
LEFT JOIN lang.text text
5050
ON text.translation_id = translation.id
5151
AND text.lang_id = 'EN'
52-
LEFT JOIN text originalText
52+
LEFT JOIN lang.text originalText
5353
ON originalText.translation_id = translation.id
5454
AND originalText.lang_id= lang.id`;
5555
await queryRunner.query(view);

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.