import { MigrationInterface, QueryRunner, Table } from "typeorm";

export class CreateRecipeTable1758959405239 implements MigrationInterface {

    public async up(queryRunner: QueryRunner): Promise<void> {
        // Create table
        await queryRunner.createTable(
            new Table({
                name: "recipe",
                columns: [
                    {
                        name: "id",
                        type: "uuid",
                        isPrimary: true,
                        isGenerated: true,
                        generationStrategy: "uuid",
                    },
                    {
                        name: "amount",
                        type: "varchar",
                        isNullable: true,
                    },
                    {
                        name: "amount_description",
                        type: "varchar",
                        isNullable: true,
                    },
                    {
                        name: "create_date",
                        type: "timestamp",
                        default: "now()",
                    },
                    {
                        name: "update_date",
                        type: "timestamp",
                        default: "now()",
                    },
                ],
            }),
            true
        );
    }

    public async down(queryRunner: QueryRunner): Promise<void> {
        // Drop the table
        await queryRunner.dropTable("recipe");
    }
}
