@luminati-io/knex
Version:
A batteries-included SQL query & schema builder for PostgresSQL, MySQL, CockroachDB, MSSQL and SQLite3
36 lines (28 loc) • 832 B
JavaScript
/* eslint max-len: 0 */
const ViewCompiler = require('../../../schema/viewcompiler.js');
class ViewCompiler_PG extends ViewCompiler {
constructor(client, viewCompiler) {
super(client, viewCompiler);
}
renameColumn(from, to) {
return this.pushQuery({
sql: `alter view ${this.viewName()} rename ${this.formatter.wrap(
from
)} to ${this.formatter.wrap(to)}`,
});
}
defaultTo(column, defaultValue) {
return this.pushQuery({
sql: `alter view ${this.viewName()} alter ${this.formatter.wrap(
column
)} set default ${defaultValue}`,
});
}
createOrReplace() {
this.createQuery(this.columns, this.selectQuery, false, true);
}
createMaterializedView() {
this.createQuery(this.columns, this.selectQuery, true);
}
}
module.exports = ViewCompiler_PG;