mirror of
https://github.com/Fabio286/antares.git
synced 2025-06-05 21:59:22 +02:00
feat(PostgreSQL): export views
This commit is contained in:
@ -160,7 +160,7 @@ SET row_security = off;\n\n\n`;
|
|||||||
|
|
||||||
async * getTableInsert (tableName) {
|
async * getTableInsert (tableName) {
|
||||||
let rowCount = 0;
|
let rowCount = 0;
|
||||||
let sqlStr = '';
|
const sqlStr = '';
|
||||||
|
|
||||||
const countResults = await this._client.raw(`SELECT COUNT(1) as count FROM "${tableName}"`);
|
const countResults = await this._client.raw(`SELECT COUNT(1) as count FROM "${tableName}"`);
|
||||||
if (countResults.rows.length === 1) rowCount = countResults.rows[0].count;
|
if (countResults.rows.length === 1) rowCount = countResults.rows[0].count;
|
||||||
@ -266,8 +266,6 @@ SET row_security = off;\n\n\n`;
|
|||||||
yield sqlInsertString;
|
yield sqlInsertString;
|
||||||
}
|
}
|
||||||
|
|
||||||
sqlStr = ';\n\n';
|
|
||||||
|
|
||||||
yield sqlStr;
|
yield sqlStr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -313,10 +311,8 @@ SET row_security = off;\n\n\n`;
|
|||||||
let sqlString = '';
|
let sqlString = '';
|
||||||
|
|
||||||
for (const view of views) {
|
for (const view of views) {
|
||||||
sqlString += `DROP VIEW IF EXISTS '${view.viewname}';\n`;
|
sqlString += `\nDROP VIEW IF EXISTS '${view.viewname}';\n`;
|
||||||
const viewSyntax = await this.getCreateTable(view.viewname);
|
sqlString += `\nCREATE VIEW "${view.viewname}" AS \n${view.definition}\n`;
|
||||||
sqlString += viewSyntax.replaceAll('`' + this.schemaName + '`.', '');
|
|
||||||
sqlString += '\n';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return sqlString;
|
return sqlString;
|
||||||
|
Reference in New Issue
Block a user