@onivoro/server-typeorm-postgres 0.1.28 → 0.1.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -5,7 +5,8 @@ class SqlWriter {
|
|
|
5
5
|
static addColumn(table, option) {
|
|
6
6
|
const notNullExpression = option.isPrimary ? ` PRIMARY KEY ` : (option.isNullable ? '' : ' NOT NULL ');
|
|
7
7
|
const foreignKey = option.foreignKeyConstraintName ? ` REFERENCES ${option.foreignKeyConstraintName} ` : '';
|
|
8
|
-
|
|
8
|
+
const uniqueExpression = option.isUnique ? ' UNIQUE ' : '';
|
|
9
|
+
return `ALTER TABLE "${table}" ADD "${option.name}" ${option.type}${notNullExpression}${uniqueExpression}${SqlWriter.getDefaultValueExpression(option)}${foreignKey}`;
|
|
9
10
|
}
|
|
10
11
|
static createTable(table, options) {
|
|
11
12
|
const cols = options.map(option => SqlWriter.addColumn(table, option).replace(`ALTER TABLE "${table}" ADD `, '')).join(',\n');
|
|
@@ -5,7 +5,8 @@ class SqlWriter {
|
|
|
5
5
|
static addColumn(table, option) {
|
|
6
6
|
const notNullExpression = option.isPrimary ? ` PRIMARY KEY ` : (option.isNullable ? '' : ' NOT NULL ');
|
|
7
7
|
const foreignKey = option.foreignKeyConstraintName ? ` REFERENCES ${option.foreignKeyConstraintName} ` : '';
|
|
8
|
-
|
|
8
|
+
const uniqueExpression = option.isUnique ? ' UNIQUE ' : '';
|
|
9
|
+
return `ALTER TABLE "${table}" ADD "${option.name}" ${option.type}${notNullExpression}${uniqueExpression}${SqlWriter.getDefaultValueExpression(option)}${foreignKey}`;
|
|
9
10
|
}
|
|
10
11
|
static createTable(table, options) {
|
|
11
12
|
const cols = options.map(option => SqlWriter.addColumn(table, option).replace(`ALTER TABLE "${table}" ADD `, '')).join(',\n');
|