UserProfiles.migrations 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. :VERSION 1 # -------------------------------
  2. begin;
  3. CREATE TABLE classifieds (
  4. "classifieduuid" char(36) NOT NULL,
  5. "creatoruuid" char(36) NOT NULL,
  6. "creationdate" integer NOT NULL,
  7. "expirationdate" integer NOT NULL,
  8. "category" varchar(20) NOT NULL,
  9. "name" varchar(255) NOT NULL,
  10. "description" text NOT NULL,
  11. "parceluuid" char(36) NOT NULL,
  12. "parentestate" integer NOT NULL,
  13. "snapshotuuid" char(36) NOT NULL,
  14. "simname" varchar(255) NOT NULL,
  15. "posglobal" varchar(255) NOT NULL,
  16. "parcelname" varchar(255) NOT NULL,
  17. "classifiedflags" integer NOT NULL,
  18. "priceforlisting" integer NOT NULL,
  19. constraint classifiedspk PRIMARY KEY ("classifieduuid")
  20. );
  21. CREATE TABLE usernotes (
  22. "useruuid" varchar(36) NOT NULL,
  23. "targetuuid" varchar(36) NOT NULL,
  24. "notes" text NOT NULL,
  25. constraint usernoteuk UNIQUE ("useruuid","targetuuid")
  26. );
  27. CREATE TABLE userpicks (
  28. "pickuuid" varchar(36) NOT NULL,
  29. "creatoruuid" varchar(36) NOT NULL,
  30. "toppick" boolean NOT NULL,
  31. "parceluuid" varchar(36) NOT NULL,
  32. "name" varchar(255) NOT NULL,
  33. "description" text NOT NULL,
  34. "snapshotuuid" varchar(36) NOT NULL,
  35. "user" varchar(255) NOT NULL,
  36. "originalname" varchar(255) NOT NULL,
  37. "simname" varchar(255) NOT NULL,
  38. "posglobal" varchar(255) NOT NULL,
  39. "sortorder" integer NOT NULL,
  40. "enabled" boolean NOT NULL,
  41. PRIMARY KEY ("pickuuid")
  42. );
  43. CREATE TABLE userprofile (
  44. "useruuid" varchar(36) NOT NULL,
  45. "profilePartner" varchar(36) NOT NULL,
  46. "profileAllowPublish" bytea NOT NULL,
  47. "profileMaturePublish" bytea NOT NULL,
  48. "profileURL" varchar(255) NOT NULL,
  49. "profileWantToMask" integer NOT NULL,
  50. "profileWantToText" text NOT NULL,
  51. "profileSkillsMask" integer NOT NULL,
  52. "profileSkillsText" text NOT NULL,
  53. "profileLanguages" text NOT NULL,
  54. "profileImage" varchar(36) NOT NULL,
  55. "profileAboutText" text NOT NULL,
  56. "profileFirstImage" varchar(36) NOT NULL,
  57. "profileFirstText" text NOT NULL,
  58. PRIMARY KEY ("useruuid")
  59. );
  60. commit;
  61. :VERSION 2 # -------------------------------
  62. begin;
  63. CREATE TABLE userdata (
  64. "UserId" char(36) NOT NULL,
  65. "TagId" varchar(64) NOT NULL,
  66. "DataKey" varchar(255),
  67. "DataVal" varchar(255),
  68. PRIMARY KEY ("UserId","TagId")
  69. );
  70. commit;
  71. :VERSION 3 # -------------------------------
  72. begin;
  73. CREATE TABLE usersettings (
  74. "useruuid" char(36) NOT NULL,
  75. "imviaemail" bytea NOT NULL,
  76. "visible" bytea NOT NULL,
  77. PRIMARY KEY ("useruuid")
  78. );
  79. commit;
  80. :VERSION 4
  81. BEGIN;
  82. -- Classifieds
  83. ALTER TABLE classifieds DROP CONSTRAINT classifiedspk;
  84. ALTER TABLE classifieds ALTER COLUMN classifieduuid SET DATA TYPE uuid using classifieduuid::uuid;
  85. ALTER TABLE classifieds ALTER COLUMN creatoruuid SET DATA TYPE uuid using creatoruuid::uuid;
  86. ALTER TABLE classifieds ALTER COLUMN parceluuid SET DATA TYPE uuid using parceluuid::uuid;
  87. ALTER TABLE classifieds ALTER COLUMN snapshotuuid SET DATA TYPE uuid using snapshotuuid::uuid;
  88. ALTER TABLE classifieds ADD CONSTRAINT classifiedspk PRIMARY KEY (classifieduuid);
  89. -- Notes
  90. ALTER TABLE usernotes DROP CONSTRAINT usernoteuk;
  91. ALTER TABLE usernotes ALTER COLUMN useruuid SET DATA TYPE uuid USING useruuid::uuid;
  92. ALTER TABLE usernotes ALTER COLUMN targetuuid SET DATA TYPE uuid USING targetuuid::uuid;
  93. ALTER TABLE usernotes ADD CONSTRAINT usernoteuk UNIQUE (useruuid,targetuuid);
  94. -- Userpicks
  95. ALTER TABLE userpicks DROP CONSTRAINT userpicks_pkey;
  96. ALTER TABLE userpicks ALTER COLUMN pickuuid SET DATA TYPE uuid USING pickuuid::uuid;
  97. ALTER TABLE userpicks ALTER COLUMN creatoruuid SET DATA TYPE uuid USING creatoruuid::uuid;
  98. ALTER TABLE userpicks ALTER COLUMN parceluuid SET DATA TYPE uuid USING parceluuid::uuid;
  99. ALTER TABLE userpicks ALTER COLUMN parceluuid SET DATA TYPE uuid USING parceluuid::uuid;
  100. ALTER TABLE userpicks ADD PRIMARY KEY (pickuuid);
  101. -- Userprofile
  102. ALTER TABLE userprofile DROP CONSTRAINT userprofile_pkey;
  103. ALTER TABLE userprofile ALTER COLUMN useruuid SET DATA TYPE uuid USING useruuid::uuid;
  104. ALTER TABLE userprofile ALTER COLUMN "profilePartner" SET DATA TYPE uuid USING "profilePartner"::uuid;
  105. -- Force column conversions
  106. ALTER TABLE userprofile ALTER COLUMN "profileAllowPublish" SET DATA TYPE boolean USING CASE WHEN false THEN false ELSE true END;
  107. ALTER TABLE userprofile ALTER COLUMN "profileMaturePublish" SET DATA TYPE boolean USING CASE WHEN false THEN false ELSE true END;
  108. ALTER TABLE userprofile ALTER COLUMN "profileImage" SET DATA TYPE uuid USING "profileImage"::uuid;
  109. ALTER TABLE userprofile ALTER COLUMN "profileFirstImage" SET DATA TYPE uuid USING "profileFirstImage"::uuid;
  110. ALTER TABLE userprofile ADD PRIMARY KEY (useruuid);
  111. -- Userdata
  112. ALTER TABLE userdata DROP CONSTRAINT userdata_pkey;
  113. ALTER TABLE userdata ALTER COLUMN "UserId" SET DATA TYPE uuid USING "UserId"::uuid;
  114. ALTER TABLE userdata ALTER COLUMN "UserId" SET DATA TYPE uuid USING "UserId"::uuid;
  115. ALTER TABLE userdata ADD PRIMARY KEY ("UserId","TagId");
  116. -- Usersettings
  117. ALTER TABLE usersettings DROP CONSTRAINT usersettings_pkey;
  118. ALTER TABLE usersettings ALTER COLUMN useruuid SET DATA TYPE uuid USING useruuid::uuid;
  119. ALTER TABLE usersettings ALTER COLUMN visible SET DATA TYPE boolean USING CASE WHEN false THEN false ELSE true END;
  120. ALTER TABLE usersettings ADD COLUMN email varchar(254) NOT NULL;
  121. ALTER TABLE usersettings ADD PRIMARY KEY (useruuid);
  122. COMMIT;
  123. :VERSION 5 # -------------------------------
  124. BEGIN;
  125. ALTER TABLE usersettings ALTER COLUMN imviaemail SET DATA TYPE boolean USING CASE WHEN false THEN false ELSE true END;
  126. COMMIT;