| 1234567891011121314151617181920212223242526272829303132 |
- 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<int64?>("id")
- .primary_key()
- .auto_increment();
- t.column<string>("name")
- .not_null();
- t.column<string>("category")
- .not_null();
- t.column<double?>("price");
- t.column<int64?>("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");
- }
- }
|