mirror of
https://github.com/knex/knex.git
synced 2025-07-13 03:50:42 +00:00

Co-authored-by: Drew Royster <drew.124@gmail.com> Co-authored-by: Kendra Bryant <kendraa@utahcounty.gov> Co-authored-by: Matt Bailey <bailey.matthewr@gmail.com>
23 lines
692 B
JavaScript
23 lines
692 B
JavaScript
const Trigger = require('./trigger');
|
|
|
|
// helper function for pushAdditional in increments() and bigincrements()
|
|
function createAutoIncrementTriggerAndSequence(columnCompiler) {
|
|
const trigger = new Trigger(columnCompiler.client.version);
|
|
|
|
// TODO Add warning that sequence etc is created
|
|
columnCompiler.pushAdditional(function () {
|
|
const tableName = this.tableCompiler.tableNameRaw;
|
|
const schemaName = this.tableCompiler.schemaNameRaw;
|
|
const createTriggerSQL = trigger.createAutoIncrementTrigger(
|
|
this.client.logger,
|
|
tableName,
|
|
schemaName
|
|
);
|
|
this.pushQuery(createTriggerSQL);
|
|
});
|
|
}
|
|
|
|
module.exports = {
|
|
createAutoIncrementTriggerAndSequence,
|
|
};
|