|
1 | 1 | module.exports = { |
2 | 2 | createDatabase: 'CREATE DATABASE "${name}" AS ${databaseOptions};', |
3 | 3 | createSession: 'SET SESSION DATABASE "${name}";', |
| 4 | + dropDatabase: 'DROP DATABASE "${databaseName}";', |
| 5 | + modifyDatabase: 'MODIFY DATABASE "${databaseName}" AS ${databaseOptions};', |
| 6 | + commentDatabase: 'COMMENT ON DATABASE ${databaseName}\nIS ${comment};', |
| 7 | + |
4 | 8 | columnDefinition: |
5 | | - '"${name}" ${type}${inlineLength}${not_null}${uppercase}${caseSpecific}${format}${default}${storageFormat}${characterSet}${withSchema}${autoColumn}${compress}${compressUsing}${decompressUsing}${inlineCheckConstraint}${inlineUniqueConstraint}${inlinePKConstraint}', |
| 9 | + '${name}${type}${inlineLength}${not_null}${uppercase}${caseSpecific}${format}${default}${storageFormat}${characterSet}${withSchema}${autoColumn}${compress}${compressUsing}${decompressUsing}${inlineCheckConstraint}${inlineUniqueConstraint}${inlinePKConstraint}', |
6 | 10 | createTable: |
7 | 11 | 'CREATE${tableSet}${temporary}${traceTable} TABLE ${name}${tableOptions} (\n' + |
8 | 12 | '\t\t${column_definitions}${keyConstraints}${checkConstraints}${foreignKeyConstraints}\n' + |
9 | | - '\t)${tableIndexes}${tablePreservation};\n', |
| 13 | + '\t)${tableIndexes}${tablePreservation};', |
10 | 14 | createAsSelectTable: |
11 | 15 | 'CREATE${tableSet}${temporary} TABLE ${name}${tableOptions} (\n' + |
12 | 16 | '\t\t${column_definitions}${keyConstraints}${checkConstraints}${foreignKeyConstraints}\n' + |
13 | 17 | '\t)' + |
14 | 18 | '\n\tAS (\n' + |
15 | 19 | '\t${selectStatement} ' + |
16 | | - '\n\t)${tableIndexes}${tablePreservation};\n', |
17 | | - createErrorTable: 'CREATE ERROR TABLE ${tableName} FOR ${targetDataTable};\n', |
| 20 | + '\n\t)${tableIndexes}${tablePreservation};', |
| 21 | + createErrorTable: 'CREATE ERROR TABLE ${tableName} FOR ${targetDataTable};', |
18 | 22 | createForeignTable: |
19 | 23 | 'CREATE FOREIGN TABLE ${name}${tableOptions} (\n' + |
20 | 24 | '\t\t${column_definitions}${keyConstraints}${checkConstraints}${foreignKeyConstraints}\n' + |
21 | 25 | '\t)\n' + |
22 | 26 | '\tUSING (\n' + |
23 | 27 | '\t${usingOptions}\n' + |
24 | | - '\t)${tableIndexes}${tablePreservation};\n', |
| 28 | + '\t)${tableIndexes}${tablePreservation};', |
25 | 29 | createHashIndex: |
26 | 30 | 'CREATE HASH INDEX ${indexName}${indexOptions} (\n' + |
27 | 31 | '\t\t${indexKeys}' + |
28 | 32 | '\n\t)' + |
29 | | - '\n\tON ${tableName}${orderBy};\n', |
30 | | - createJoinIndex: 'CREATE JOIN INDEX ${indexName}${indexOptions}' + '\n\tAS ${selectStatement};\n', |
31 | | - createKeyConstraint: 'CONSTRAINT ${constraintName}${constraintType}${columns}', |
| 33 | + '\n\tON ${tableName}${orderBy};', |
| 34 | + createJoinIndex: 'CREATE JOIN INDEX ${indexName}${indexOptions}' + '\n\tAS ${selectStatement};', |
| 35 | + createKeyConstraint: '${constraintName}${constraintType} (${columns})', |
32 | 36 | checkConstraint: '${name}${expression}', |
33 | | - createForeignKeyConstraint: 'FOREIGN KEY (${foreignKey}) REFERENCES ${checkOption} ${primaryTable} (${primaryKey})', |
34 | | - createView: 'CREATE${recursive} VIEW ${name} (\n' + '\t${columnList}\n' + ')\nAS ${selectStatement};\n', |
| 37 | + |
| 38 | + createForeignKeyConstraint: |
| 39 | + '${constraintName}FOREIGN KEY (${foreignKey}) REFERENCES ${checkOption} ${primaryTable} (${primaryKey})', |
| 40 | + dropForeignKeyUnnamed: |
| 41 | + 'ALTER TABLE ${tableName} DROP FOREIGN KEY (${foreignKey}) REFERENCES ${primaryTable} (${primaryKey});', |
| 42 | + |
| 43 | + createView: 'CREATE${recursive} VIEW ${name} (\n' + '\t${columnList}\n' + ')\nAS ${selectStatement};', |
35 | 44 | viewSelectStatement: 'SELECT ${keys}\n\tFROM ${tableName}', |
36 | 45 | createStructuredType: |
37 | | - 'CREATE TYPE ${typeName} AS (\n' + '\t${columnDefinitions}' + '\n)\n' + 'NOT FINAL${methodSpecification};\n', |
38 | | - createDistinctType: 'CREATE TYPE ${typeName} AS ${baseType} FINAL${methodSpecification};\n', |
39 | | - createArrayType: 'CREATE TYPE ${typeName} AS ${baseType}${default};\n', |
40 | | - |
41 | | - dropDatabase: 'DROP DATABASE "${databaseName}";\n', |
42 | | - modifyDatabase: 'MODIFY DATABASE "${databaseName}" AS ${databaseOptions};\n', |
| 46 | + 'CREATE TYPE ${typeName} AS (\n' + '\t${columnDefinitions}' + '\n)\n' + 'NOT FINAL${methodSpecification};', |
| 47 | + createDistinctType: 'CREATE TYPE ${typeName} AS ${baseType} FINAL${methodSpecification};', |
| 48 | + createArrayType: 'CREATE TYPE ${typeName} AS ${baseType}${default};', |
43 | 49 |
|
44 | | - dropTable: 'DROP ${temporary}TABLE ${name};\n', |
| 50 | + dropTable: 'DROP ${temporary}TABLE ${name};', |
45 | 51 | alterTable: 'ALTER TABLE ${tableName}${tableOptions}${alterStatement};', |
| 52 | + renameTable: 'RENAME TABLE ${oldName} TO ${newName};', |
| 53 | + commentTable: 'COMMENT ON TABLE ${tableName}\nIS ${comment};', |
46 | 54 |
|
47 | 55 | addColumn: ' ADD ${columnDefinition}', |
| 56 | + alterColumn: 'ALTER TABLE ${tableName} ADD ${columnName} ${columnDefinition};', |
48 | 57 | dropColumn: ' DROP ${name}', |
49 | 58 | rename: ' RENAME ${oldName} TO ${newName}', |
| 59 | + commentColumn: 'COMMENT ON COLUMN ${columnName}\nIS ${comment};', |
50 | 60 |
|
51 | 61 | dropCheckConstraint: ' DROP CONSTRAINT ${name} CHECK', |
52 | | - addCheckConstraint: ' ADD CONSTRAINT ${name} ${expression}', |
53 | | - modifyCheckConstraint: ' MODIFY CONSTRAINT ${name} ${expression}', |
| 62 | + addCheckConstraint: ' ADD ${constraintName}${expression}', |
| 63 | + alterCheckConstraint: ' ADD ${constraintName}${expression}', |
54 | 64 |
|
| 65 | + createSecondaryIndex: 'CREATE ${indexStatement} ON ${tableName};', |
55 | 66 | dropSecondaryIndex: 'DROP INDEX ${indexName} ON ${tableName};', |
56 | 67 | dropIndex: 'DROP${indexType} INDEX ${indexName};', |
57 | 68 |
|
58 | 69 | dropView: 'DROP VIEW ${viewName};', |
59 | 70 | renameView: 'RENAME VIEW ${oldViewName} TO ${newViewName};', |
| 71 | + commentView: 'COMMENT ON VIEW ${viewName}\nIS ${comment};', |
| 72 | + |
| 73 | + dropConstraint: 'ALTER TABLE ${tableName} DROP CONSTRAINT ${constraintName};', |
| 74 | + |
| 75 | + alterPrimaryKey: 'ALTER TABLE ${tableName} ADD ${constraintName}PRIMARY KEY (${columns});', |
| 76 | + alterUniqueKey: 'ALTER TABLE ${tableName} ADD ${constraintName}UNIQUE (${columns});', |
| 77 | + |
| 78 | + dropUnnamedIndex: 'DROP INDEX (${columns}) ON ${tableName};', |
60 | 79 | }; |
0 commit comments