Beginning of work on templates.

This commit is contained in:
Tomas Bures 2018-02-13 23:50:13 +01:00
parent 47b8d80c22
commit 508d6b3b2f
40 changed files with 1685 additions and 1031 deletions

View file

@ -0,0 +1,25 @@
const entityTypesWithFiles = ['template', 'campaign'];
exports.up = (knex, Promise) => (async() => {
for (const entityType of entityTypesWithFiles) {
await knex.schema.createTable(`files_${entityType}`, table => {
table.increments('id').primary();
table.integer('entity').unsigned().notNullable().references('templates.id');
table.string('filename');
table.string('originalname');
table.string('mimetype');
table.string('encoding');
table.integer('size');
table.timestamp('created').defaultTo(knex.fn.now());
table.index(['entity', 'originalname'])
})
}
})();
exports.down = (knex, Promise) => (async() => {
for (const entityType of entityTypesWithFiles) {
await knex.schema.dropTable(`files_${entityType}`);
}
})();