... | @@ -54,7 +54,8 @@ The tables created in Postgrees SQL are made through the knex and can be found i |
... | @@ -54,7 +54,8 @@ The tables created in Postgrees SQL are made through the knex and can be found i |
|
**recipes**
|
|
**recipes**
|
|
|
|
|
|
Script for table creation:
|
|
Script for table creation:
|
|
`
|
|
|
|
|
|
```
|
|
export async function up(knex: Knex): Promise<void> {
|
|
export async function up(knex: Knex): Promise<void> {
|
|
return knex.schema
|
|
return knex.schema
|
|
.hasTable('recipes')
|
|
.hasTable('recipes')
|
... | @@ -74,22 +75,23 @@ export async function up(knex: Knex): Promise<void> { |
... | @@ -74,22 +75,23 @@ export async function up(knex: Knex): Promise<void> { |
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
`
|
|
```
|
|
|
|
|
|
Then it was necessary to add a script to change the recipes table. It is necessary to have a new column containing the information `active`, as the recipes will not have hard delete, only soft delete. In this case, the change follows:
|
|
Then it was necessary to add a script to change the recipes table. It is necessary to have a new column containing the information `active`, as the recipes will not have hard delete, only soft delete. In this case, the change follows:
|
|
|
|
|
|
`
|
|
```
|
|
export async function up(knex: Knex): Promise<void> {
|
|
export async function up(knex: Knex): Promise<void> {
|
|
return knex.schema.alterTable('recipes', (table) => {
|
|
return knex.schema.alterTable('recipes', (table) => {
|
|
table.integer('active', 1).notNullable().defaultTo(1);
|
|
table.integer('active', 1).notNullable().defaultTo(1);
|
|
});
|
|
});
|
|
}
|
|
}
|
|
`
|
|
```
|
|
|
|
|
|
**steps**
|
|
**steps**
|
|
|
|
|
|
All recipes need steps to be made, below the script:
|
|
All recipes need steps to be made, below the script:
|
|
|
|
|
|
`
|
|
```
|
|
export async function up(knex: Knex): Promise<void> {
|
|
export async function up(knex: Knex): Promise<void> {
|
|
return knex.schema.hasTable('steps')
|
|
return knex.schema.hasTable('steps')
|
|
.then((exists) => {
|
|
.then((exists) => {
|
... | @@ -104,12 +106,12 @@ export async function up(knex: Knex): Promise<void> { |
... | @@ -104,12 +106,12 @@ export async function up(knex: Knex): Promise<void> { |
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
`
|
|
```
|
|
|
|
|
|
**tags**
|
|
**tags**
|
|
|
|
|
|
At this point, we need put some tags, so here was the script:
|
|
At this point, we need put some tags, so here was the script:
|
|
`
|
|
```
|
|
export async function up(knex: Knex): Promise<void[]> {
|
|
export async function up(knex: Knex): Promise<void[]> {
|
|
return Promise.all([
|
|
return Promise.all([
|
|
knex.schema
|
|
knex.schema
|
... | @@ -125,4 +127,4 @@ export async function up(knex: Knex): Promise<void[]> { |
... | @@ -125,4 +127,4 @@ export async function up(knex: Knex): Promise<void[]> { |
|
}),
|
|
}),
|
|
]);
|
|
]);
|
|
}
|
|
}
|
|
` |
|
``` |
|
\ No newline at end of file |
|
\ No newline at end of file |