( driver: BaseDriver, con: DatabaseTableColumnConstraint, tableName: string )
| 138 | } |
| 139 | |
| 140 | function generateConstraintModifyScript( |
| 141 | driver: BaseDriver, |
| 142 | con: DatabaseTableColumnConstraint, |
| 143 | tableName: string |
| 144 | ) { |
| 145 | let keyName = ""; |
| 146 | if (con?.primaryKey) { |
| 147 | keyName = `${tableName}_pkey`; |
| 148 | } |
| 149 | if (con?.foreignKey) { |
| 150 | keyName = `${tableName}_${con.foreignKey.foreignTableName}_${con.foreignKey.columns?.join("")}_fkey`; |
| 151 | } |
| 152 | if (con.unique) { |
| 153 | keyName = `${tableName}_${con.uniqueColumns?.join("")}_key`; |
| 154 | } |
| 155 | |
| 156 | return [ |
| 157 | `DROP CONSTRAINT IF EXISTS ${keyName}`, |
| 158 | `ADD CONSTRAINT ${keyName} ${generateConstraintScript(driver, con)}`, |
| 159 | ]; |
| 160 | } |
| 161 | |
| 162 | //https://www.postgresql.org/docs/current/sql-createtable.html |
| 163 | export function generatePostgresSchemaChange( |
no test coverage detected