2016-03-29 12:02:06 +02:00

14 lines
677 B
Plaintext
Executable File

/**
* Create the `<%= tableName %>` table to make relationships
* between `<%= details.collection %>` and `<%= relationship.collection %>`.
*/
connection.schema.createTableIfNotExists('<%= tableName %>', function (table) {
table.integer('<%= details.attribute %>_<%= details.column %>').unsigned().references('<%= details.column %>').inTable('<%= details.collection %>');
table.integer('<%= relationship.attribute %>_<%= relationship.column %>').unsigned().references('<%= relationship.column %>').inTable('<%= relationship.collection %>');
}).catch(function (err) {
console.log('Impossible to create the `<%= tableName %>` relation table.');
console.log(err)
}),