using InvercargillSql; using InvercargillSql.Migrations; /** * Migration to create the products table with category index. */ public class V002_CreateProducts : Migration { public override string migration_namespace { get { return "app"; } } public override uint64 serial { get { return 2; } } public override string name { get { return "CreateProducts"; } } public override void up(MigrationBuilder b) throws SqlError { b.create_table("products", t => { t.column("id") .primary_key() .auto_increment(); t.column("name") .not_null(); t.column("category") .not_null(); t.column("price"); t.column("stock"); // Create index on category for fast category-based queries t.index("idx_products_category").on_column("category"); }); } public override void down(MigrationBuilder b) throws SqlError { b.drop_table("products"); } }