1
+ -- WIKIENTRIES_RELATIONSHIP_TYPE
1
2
CREATE TABLE "wikientries_relationship_type " (
2
3
" id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
3
4
" name" varchar (50 ) NOT NULL ,
@@ -25,6 +26,7 @@ VALUES (
25
26
' 2024-12-13 12:00:00' ,
26
27
' 2024-12-13 12:00:00'
27
28
);
29
+ -- WIKIENTRIES_RELATIONSHIP - ADD LINK_TYPE_ID AND CAMPAIGN_ID
28
30
-- Migrate wikientries_relationships to a table that has a link_type_id fk column
29
31
CREATE TABLE wikientries_relationships_new (
30
32
" id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
@@ -34,7 +36,7 @@ CREATE TABLE wikientries_relationships_new (
34
36
" weight" integer ,
35
37
" creation_datetime" datetime NOT NULL ,
36
38
" update_datetime" datetime NOT NULL ,
37
- " campaign_id" integer ,
39
+ " campaign_id" integer REFERENCES " wikientries_campaign " ( " id " ) DEFERRABLE INITIALLY DEFERRED ,
38
40
" link_type_id" integer NOT NULL DEFAULT 1 ,
39
41
FOREIGN KEY (link_type_id) REFERENCES wikientries_relationship_type (id)
40
42
);
@@ -64,4 +66,71 @@ FROM wikientries_relationships;
64
66
DROP TABLE wikientries_relationships;
65
67
-- Rename the new table to the old table's name
66
68
ALTER TABLE wikientries_relationships_new
67
- RENAME TO wikientries_relationships;
69
+ RENAME TO wikientries_relationships;
70
+ -- MAP_MARKERTYPE ADD CAMPAIGN_ID COLUMN
71
+ -- Extend map marker type to have an optional campaign_id column
72
+ CREATE TABLE map_markertype_new (
73
+ " id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
74
+ " name" varchar (50 ) NOT NULL ,
75
+ " icon" varchar (20 ) NOT NULL ,
76
+ " is_text_marker" bool NOT NULL ,
77
+ " creation_datetime" datetime NOT NULL ,
78
+ " update_datetime" datetime NOT NULL ,
79
+ " fontawesome_type" varchar (4 ) NOT NULL ,
80
+ " color" varchar (20 ) NOT NULL ,
81
+ " campaign_id" integer REFERENCES " wikientries_campaign" (" id" ) DEFERRABLE INITIALLY DEFERRED
82
+ );
83
+ -- Copy the data from the old table to the new table
84
+ INSERT INTO map_markertype_new (
85
+ " id" ,
86
+ " name" ,
87
+ " icon" ,
88
+ " is_text_marker" ,
89
+ " creation_datetime" ,
90
+ " update_datetime" ,
91
+ " fontawesome_type" ,
92
+ " color" ,
93
+ " campaign_id"
94
+ )
95
+ SELECT " id" ,
96
+ " name" ,
97
+ " icon" ,
98
+ " is_text_marker" ,
99
+ " creation_datetime" ,
100
+ " update_datetime" ,
101
+ " fontawesome_type" ,
102
+ " color" ,
103
+ NULL AS " campaign_id"
104
+ FROM map_markertype;
105
+ -- Drop the old table
106
+ DROP TABLE map_markertype;
107
+ -- Rename the new table to the old table's name
108
+ ALTER TABLE map_markertype_new
109
+ RENAME TO map_markertype;
110
+ -- WIKIENTRIES_PLAYERCLASS ADD CAMPAIGN_ID COLUMN
111
+ CREATE TABLE "wikientries_playerclass_new " (
112
+ " id" integer NOT NULL PRIMARY KEY AUTOINCREMENT,
113
+ " name" varchar (200 ) NOT NULL UNIQUE,
114
+ " campaign_id" integer REFERENCES " wikientries_campaign" (" id" ) DEFERRABLE INITIALLY DEFERRED,
115
+ " creation_datetime" datetime NOT NULL ,
116
+ " update_datetime" datetime NOT NULL
117
+ );
118
+ -- Copy the data from the old table to the new table
119
+ INSERT INTO wikientries_playerclass_new (
120
+ " id" ,
121
+ " name" ,
122
+ " campaign_id" ,
123
+ " creation_datetime" ,
124
+ " update_datetime"
125
+ )
126
+ SELECT " id" ,
127
+ " name" ,
128
+ NULL ,
129
+ " creation_datetime" ,
130
+ " update_datetime"
131
+ FROM wikientries_playerclass;
132
+ -- Drop the old table
133
+ DROP TABLE wikientries_playerclass;
134
+ -- Rename the new table to the old table's name
135
+ ALTER TABLE wikientries_playerclass_new
136
+ RENAME TO wikientries_playerclass;
0 commit comments