AssetStore.migrations 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. :VERSION 1
  2. CREATE TABLE assets (
  3. "id" varchar(36) NOT NULL PRIMARY KEY,
  4. "name" varchar(64) NOT NULL,
  5. "description" varchar(64) NOT NULL,
  6. "assetType" smallint NOT NULL,
  7. "local" smallint NOT NULL,
  8. "temporary" smallint NOT NULL,
  9. "data" bytea NOT NULL
  10. ) ;
  11. :VERSION 2
  12. BEGIN TRANSACTION;
  13. CREATE TABLE Tmp_assets
  14. (
  15. "id" varchar(36) NOT NULL,
  16. "name" varchar(64) NOT NULL,
  17. "description" varchar(64) NOT NULL,
  18. "assetType" smallint NOT NULL,
  19. "local" boolean NOT NULL,
  20. "temporary" boolean NOT NULL,
  21. "data" bytea NOT NULL
  22. ) ;
  23. INSERT INTO Tmp_assets ("id", "name", "description", "assetType", "local", "temporary", "data")
  24. SELECT "id", "name", "description", "assetType", case when "local" = 1 then true else false end, case when "temporary" = 1 then true else false end, "data"
  25. FROM assets ;
  26. DROP TABLE assets;
  27. Alter table Tmp_assets
  28. rename to assets;
  29. ALTER TABLE assets ADD PRIMARY KEY ("id");
  30. COMMIT;
  31. :VERSION 3
  32. BEGIN TRANSACTION;
  33. ALTER TABLE assets add "create_time" integer default 0;
  34. ALTER TABLE assets add "access_time" integer default 0;
  35. COMMIT;
  36. :VERSION 4
  37. BEGIN TRANSACTION;
  38. CREATE TABLE Tmp_assets
  39. (
  40. "id" uuid NOT NULL,
  41. "name" varchar(64) NOT NULL,
  42. "description" varchar(64) NOT NULL,
  43. "assetType" smallint NOT NULL,
  44. "local" boolean NOT NULL,
  45. "temporary" boolean NOT NULL,
  46. "data" bytea NOT NULL,
  47. "create_time" int NULL,
  48. "access_time" int NULL
  49. ) ;
  50. INSERT INTO Tmp_assets ("id", "name", "description", "assetType", "local", "temporary", "data", "create_time", "access_time")
  51. SELECT cast("id" as uuid), "name", "description", "assetType", "local", "temporary", "data", "create_time", "access_time"
  52. FROM assets ;
  53. DROP TABLE assets;
  54. Alter table Tmp_assets
  55. rename to assets;
  56. ALTER TABLE assets ADD PRIMARY KEY ("id");
  57. COMMIT;
  58. :VERSION 5
  59. DELETE FROM assets WHERE "id" = 'dc4b9f0b-d008-45c6-96a4-01dd947ac621';
  60. :VERSION 6
  61. ALTER TABLE assets ADD "asset_flags" INTEGER NOT NULL DEFAULT 0;
  62. :VERSION 7
  63. alter table assets add "creatorid" varchar(36) not null default '';
  64. :VERSION 8
  65. BEGIN TRANSACTION;
  66. COMMIT;