-
Notifications
You must be signed in to change notification settings - Fork 988
/
create-odbc_mssql.sql
270 lines (234 loc) · 6.26 KB
/
create-odbc_mssql.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
--
-- Structure for table answers :
--
CREATE TABLE [dbo].[prefix_answers] (
[qid] int DEFAULT 0 NOT NULL,
[code] nvarchar(5) NOT NULL,
[answer] ntext NOT NULL,
[default_value] nvarchar(1) DEFAULT 'N' NOT NULL,
[sortorder] nvarchar(5) NULL
)
ON [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
;
--
-- Structure for table assessments :
--
CREATE TABLE [dbo].[prefix_assessments] (
[id] int IDENTITY(1, 1) NOT NULL,
[sid] int DEFAULT 0 NOT NULL,
[scope] nvarchar(5) NOT NULL,
[gid] int DEFAULT 0 NOT NULL,
[name] text NOT NULL,
[minimum] nvarchar(50) NOT NULL,
[maximum] nvarchar(50) NOT NULL,
[message] ntext NOT NULL,
[link] ntext NOT NULL
)
ON [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
;
--
-- Structure for table conditions :
--
CREATE TABLE [dbo].[prefix_conditions] (
[cid] int IDENTITY(1, 1) NOT NULL,
[qid] int DEFAULT 0 NOT NULL,
[cqid] int DEFAULT 0 NOT NULL,
[cfieldname] nvarchar(50) NOT NULL,
[method] nvarchar(2) NOT NULL,
[value] nvarchar(5) NOT NULL
)
ON [PRIMARY]
;
--
-- Structure for table groups :
--
CREATE TABLE [dbo].[prefix_groups] (
[gid] int IDENTITY(1, 1) NOT NULL,
[sid] int DEFAULT 0 NOT NULL,
[group_name] nvarchar(100) NOT NULL,
[description] ntext NULL,
[sortorder] nvarchar(5) NULL
)
ON [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
;
--
-- Structure for table labels :
--
CREATE TABLE [dbo].[prefix_labels] (
[lid] int DEFAULT 0 NOT NULL,
[code] nvarchar(5) NOT NULL,
[title] nvarchar(100) NOT NULL,
[sortorder] nvarchar(5) NULL
)
ON [PRIMARY]
;
--
-- Structure for table labelsets :
--
CREATE TABLE [dbo].[prefix_labelsets] (
[lid] int IDENTITY(1, 1) NOT NULL,
[label_name] nvarchar(100) NOT NULL
)
ON [PRIMARY]
;
--
-- Structure for table question_attributes :
--
CREATE TABLE [dbo].[prefix_question_attributes] (
[qaid] int IDENTITY(1, 1) NOT NULL,
[qid] int NOT NULL,
[attribute] nvarchar(50) NULL,
[value] nvarchar(20) NULL
)
ON [PRIMARY]
;
CREATE TABLE [dbo].[prefix_settings_global] (
[stg_name] nvarchar(50) NOT NULL,
[stg_value] nvarchar(255) NULL
)
ON [PRIMARY]
;
--
-- Structure for table questions :
--
CREATE TABLE [dbo].[prefix_questions] (
[qid] int IDENTITY(1, 1) NOT NULL,
[sid] int DEFAULT 0 NOT NULL,
[gid] int DEFAULT 0 NOT NULL,
[type] nvarchar(1) DEFAULT 'T' NOT NULL,
[title] nvarchar(20) NOT NULL,
[question] ntext NOT NULL,
[preg] ntext NULL,
[help] ntext NULL,
[other] nvarchar(1) DEFAULT 'N' NOT NULL,
[mandatory] nvarchar(1) NULL,
[lid] int DEFAULT 0 NOT NULL
)
ON [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
;
--
-- Structure for table saved_control :
--
CREATE TABLE [dbo].[prefix_saved_control] (
[scid] int IDENTITY(1, 1) NOT NULL,
[sid] int CONSTRAINT [DF__saved_contr__sid__108B795B] DEFAULT 0 NOT NULL,
[srid] int CONSTRAINT [DF__saved_cont__srid__117F9D94] DEFAULT 0 NOT NULL,
[identifier] ntext NOT NULL,
[access_code] ntext NOT NULL,
[email] nvarchar(200) NULL,
[ip] ntext NOT NULL,
[refurl] ntext NULL,
[saved_thisstep] ntext NOT NULL,
[status] nvarchar(1) NOT NULL,
[saved_date] datetime NULL
)
ON [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
;
--
-- Structure for table surveys :
--
CREATE TABLE [dbo].[prefix_surveys] (
[sid] int NOT NULL,
[short_title] nvarchar(200) NOT NULL,
[description] ntext NULL,
[datecreated] datetime NULL,
[admin] nvarchar(50) NULL,
[active] nvarchar(1) DEFAULT 'N' NOT NULL,
[welcome] ntext NULL,
[useexpiry] nvarchar(1) DEFAULT 'N' NOT NULL,
[expires] datetime NULL,
[adminemail] nvarchar(100) NULL,
[private] nvarchar(1) NULL,
[faxto] nvarchar(20) NULL,
[format] nvarchar(1) NULL,
[template] nvarchar(100) DEFAULT 'default' NULL,
[url] nvarchar(255) NULL,
[urldescrip] nvarchar(255) NULL,
[language] nvarchar(50) NULL,
[datestamp] nvarchar(1) DEFAULT 'N' NULL,
[ipaddr] nvarchar(1) DEFAULT 'N' NULL,
[refurl] nvarchar(1) DEFAULT 'N' NULL,
[usecookie] nvarchar(1) DEFAULT 'N' NULL,
[notification] nvarchar(1) DEFAULT '0' NULL,
[allowregister] nvarchar(1) DEFAULT 'N' NULL,
[attribute1] nvarchar(255) NULL,
[attribute2] nvarchar(255) NULL,
[email_invite_subj] nvarchar(255) NULL,
[email_invite] ntext NULL,
[email_remind_subj] nvarchar(255) NULL,
[email_remind] ntext NULL,
[email_register_subj] nvarchar(255) NULL,
[email_register] ntext NULL,
[email_confirm_subj] nvarchar(255) NULL,
[email_confirm] ntext NULL,
[allowsave] nvarchar(1) DEFAULT 'Y' NULL,
[autonumber_start] bigint DEFAULT 19533676560910059 NULL,
[autoredirect] nvarchar(1) DEFAULT 'N' NULL,
[allowprev] nvarchar(1) DEFAULT 'Y' NULL
)
ON [PRIMARY]
TEXTIMAGE_ON [PRIMARY]
;
--
-- Structure for table users :
--
CREATE TABLE [dbo].[prefix_users] (
[user] nvarchar(20) NOT NULL,
[password] nvarchar(20) NOT NULL,
[security] nvarchar(10) NOT NULL
)
ON [PRIMARY]
;
--
-- Definition for indices :
--
ALTER TABLE [dbo].[prefix_assessments]
ADD CONSTRAINT [PK_assessments]
PRIMARY KEY CLUSTERED ([id])
ON [PRIMARY]
;
ALTER TABLE [dbo].[prefix_conditions]
ADD CONSTRAINT [PK_conditions]
PRIMARY KEY CLUSTERED ([cid])
ON [PRIMARY]
;
ALTER TABLE [dbo].[prefix_groups]
ADD CONSTRAINT [PK_groups]
PRIMARY KEY CLUSTERED ([gid])
ON [PRIMARY]
;
ALTER TABLE [dbo].[prefix_labelsets]
ADD CONSTRAINT [PK_labelsets]
PRIMARY KEY CLUSTERED ([lid])
ON [PRIMARY]
;
ALTER TABLE [dbo].[prefix_question_attributes]
ADD CONSTRAINT [PK_question_attributes]
PRIMARY KEY CLUSTERED ([qaid])
ON [PRIMARY]
;
ALTER TABLE [dbo].[prefix_questions]
ADD CONSTRAINT [PK_questions]
PRIMARY KEY CLUSTERED ([qid])
ON [PRIMARY]
;
ALTER TABLE [dbo].[prefix_saved_control]
ADD CONSTRAINT [PK_saved_control]
PRIMARY KEY CLUSTERED ([scid])
ON [PRIMARY]
;
ALTER TABLE [dbo].[prefix_surveys]
ADD CONSTRAINT [PK_surveys]
PRIMARY KEY CLUSTERED ([sid])
ON [PRIMARY];
ALTER TABLE [dbo].[prefix_settings_global]
ADD CONSTRAINT [PK_settings_global]
PRIMARY KEY CLUSTERED ([stg_name])
ON [PRIMARY];
-- if you change the database scheme then change this version too and implement the changes in the upgrade_*.php too
INSERT INTO [prefix_settings_global] values('DBVersion','108');