v001-create-users.vala 960 B

12345678910111213141516171819202122232425262728293031
  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 int version { get { return 1; } }
  8. public override string name { get { return "CreateUsers"; } }
  9. public override void up(MigrationBuilder b) throws SqlError {
  10. b.create_table("users", t => {
  11. t.column<int64?>("id")
  12. .primary_key()
  13. .auto_increment();
  14. t.column<string>("name")
  15. .not_null();
  16. t.column<string>("email")
  17. .unique();
  18. t.column<int64?>("age");
  19. t.column<bool?>("is_active");
  20. // Create index on email for fast lookups
  21. t.index("idx_users_email").on_column("email");
  22. });
  23. }
  24. public override void down(MigrationBuilder b) throws SqlError {
  25. b.drop_table("users");
  26. }
  27. }