v001-create-users.vala 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. using InvercargillSql;
  2. using InvercargillSql.Migrations;
  3. /**
  4. * Migration to create the users table with indexes.
  5. */
  6. public class V001_CreateUsers : Migration {
  7. public override string migration_namespace { get { return "app"; } }
  8. public override uint64 serial { get { return 1; } }
  9. public override string name { get { return "CreateUsers"; } }
  10. public override void up(MigrationBuilder b) throws SqlError {
  11. b.create_table("users", t => {
  12. t.column<int64?>("id")
  13. .primary_key()
  14. .auto_increment();
  15. t.column<string>("name")
  16. .not_null();
  17. t.column<string>("email")
  18. .unique();
  19. t.column<int64?>("age");
  20. t.column<bool?>("is_active");
  21. // Create index on email for fast lookups
  22. t.index("idx_users_email").on_column("email");
  23. });
  24. }
  25. public override void down(MigrationBuilder b) throws SqlError {
  26. b.drop_table("users");
  27. }
  28. }