2025-07-08 15:29:37 -07:00
|
|
|
/**
|
|
|
|
* @param { import("knex").Knex } knex
|
|
|
|
* @returns { Promise<void> }
|
|
|
|
*/
|
|
|
|
exports.up = function (knex) {
|
|
|
|
return knex.schema.createTable('ingredients', function (table) {
|
|
|
|
table.increments('id').primary();
|
|
|
|
table.string('name').notNullable().unique();
|
|
|
|
table.string('type');
|
|
|
|
table.string('notes');
|
|
|
|
table.timestamps(true, true);
|
|
|
|
}).
|
|
|
|
createTable('recipe_ingredients', function (table) {
|
|
|
|
table.increments('id').primary();
|
|
|
|
table.integer('recipe_id').notNullable();
|
|
|
|
table.integer('ingredient_id').notNullable();
|
|
|
|
table.string('quantity').notNullable();
|
|
|
|
table.string('unit').notNullable();
|
|
|
|
table.string('notes');
|
|
|
|
table.index(['recipe_id']);
|
|
|
|
table.index(['ingredient_id']);
|
|
|
|
table.timestamps(true, true);
|
|
|
|
}).
|
|
|
|
createTable('recipe_steps', function (table) {
|
|
|
|
table.increments('id').primary();
|
|
|
|
table.integer('recipe_id');
|
|
|
|
table.integer('step_number');
|
2025-07-08 17:26:02 -07:00
|
|
|
table.string('instruction');
|
2025-07-08 15:29:37 -07:00
|
|
|
table.unique(['recipe_id', 'step_number']);
|
|
|
|
table.index(['recipe_id'])
|
|
|
|
table.timestamps(true, true);
|
|
|
|
})
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param { import("knex").Knex } knex
|
|
|
|
* @returns { Promise<void> }
|
|
|
|
*/
|
|
|
|
exports.down = function (knex) {
|
|
|
|
return knex.schema.dropTableIfExists('ingredients')
|
|
|
|
.dropTableIfExists('recipe_ingredients')
|
|
|
|
.dropTableIfExists('recipe_steps')
|
|
|
|
};
|