aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/fixtures/db_definitions/openbase.sql
blob: c3da2efee62b3c5ef59ca546192fef0750df6c20 (plain) (blame)
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
CREATE TABLE accounts (
    id integer UNIQUE INDEX DEFAULT _rowid,
    firm_id integer,
    credit_limit integer
)
go
CREATE PRIMARY KEY accounts (id) 
go

CREATE TABLE funny_jokes (
  id integer UNIQUE INDEX DEFAULT _rowid,
  name char(50) DEFAULT NULL
)
go
CREATE PRIMARY KEY funny_jokes (id)
go

CREATE TABLE companies (
    id integer UNIQUE INDEX DEFAULT _rowid,
    type char(50),
    ruby_type char(50),
    firm_id integer,
    name char(50),
    client_of integer,
    rating integer default 1
) 
go
CREATE PRIMARY KEY companies (id) 
go

CREATE TABLE developers_projects (
    developer_id integer NOT NULL,
    project_id integer NOT NULL,
    joined_on date,
    access_level integer default 1
) 
go

CREATE TABLE developers (
    id integer UNIQUE INDEX DEFAULT _rowid,
    name char(100),
    salary integer DEFAULT 70000,
    created_at datetime,
    updated_at datetime
) 
go
CREATE PRIMARY KEY developers (id) 
go

CREATE TABLE projects (
    id integer UNIQUE INDEX DEFAULT _rowid,
    name char(100),
    type char(255)
) 
go
CREATE PRIMARY KEY projects (id) 
go

CREATE TABLE topics (
    id integer UNIQUE INDEX DEFAULT _rowid,
    title char(255),
    author_name char(255),
    author_email_address char(255),
    written_on datetime,
    bonus_time time,
    last_read date,
    content char(4096),
    approved boolean default true,
    replies_count integer default 0,
    parent_id integer,
    type char(50)
) 
go
CREATE PRIMARY KEY topics (id) 
go

CREATE TABLE customers (
    id integer UNIQUE INDEX DEFAULT _rowid,
    name char,
    balance integer default 0,
    address_street char,
    address_city char,
    address_country char,
    gps_location char
) 
go
CREATE PRIMARY KEY customers (id) 
go

CREATE TABLE orders (
    id integer UNIQUE INDEX DEFAULT _rowid,
    name char,
    billing_customer_id integer,
    shipping_customer_id integer
) 
go
CREATE PRIMARY KEY orders (id) 
go

CREATE TABLE movies (
    movieid integer UNIQUE INDEX DEFAULT _rowid,
    name text
) 
go
CREATE PRIMARY KEY movies (movieid) 
go

CREATE TABLE subscribers (
    nick CHAR(100) NOT NULL DEFAULT _rowid,
    name CHAR(100)
) 
go
CREATE PRIMARY KEY subscribers (nick) 
go

CREATE TABLE booleantests (
    id integer UNIQUE INDEX DEFAULT _rowid,
    value boolean
) 
go
CREATE PRIMARY KEY booleantests (id) 
go

CREATE TABLE defaults (
    id integer UNIQUE INDEX ,
    modified_date date default CURDATE(),
    modified_date_function date default NOW(),
    fixed_date date default '2004-01-01',
    modified_time timestamp default NOW(),
    modified_time_function timestamp default NOW(),
    fixed_time timestamp default '2004-01-01 00:00:00.000000-00',
    char1 char(1) default 'Y',
    char2 char(50) default 'a char field',
    char3 text default 'a text field'
) 
go

CREATE TABLE auto_id_tests (
    auto_id integer UNIQUE INDEX DEFAULT _rowid,
    value integer
) 
go
CREATE PRIMARY KEY auto_id_tests (auto_id) 
go

CREATE TABLE entrants (
  id integer UNIQUE INDEX ,
  name text,
  course_id integer
) 
go

CREATE TABLE colnametests (
  id integer UNIQUE INDEX ,
  references integer NOT NULL
) 
go

CREATE TABLE mixins (
  id integer UNIQUE INDEX DEFAULT _rowid,
  parent_id integer,
  type char,  
  pos integer,
  lft integer,
  rgt integer,
  root_id integer,  
  created_at timestamp,
  updated_at timestamp
) 
go
CREATE PRIMARY KEY mixins (id) 
go

CREATE TABLE people (
  id integer UNIQUE INDEX DEFAULT _rowid,
  first_name text,
  lock_version integer default 0
) 
go
CREATE PRIMARY KEY people (id) 
go

CREATE TABLE readers (
    id integer UNIQUE INDEX DEFAULT _rowid,
    post_id integer NOT NULL,
    person_id integer NOT NULL
)
go
CREATE PRIMARY KEY readers (id)
go

CREATE TABLE binaries ( 
  id integer UNIQUE INDEX DEFAULT _rowid,
  data object
) 
go
CREATE PRIMARY KEY binaries (id) 
go

CREATE TABLE computers (
  id integer UNIQUE INDEX ,
  developer integer NOT NULL,
  extendedWarranty integer NOT NULL
) 
go

CREATE TABLE posts (
  id integer UNIQUE INDEX ,
  author_id integer,
  title char(255),
  type char(255),
  body text
) 
go

CREATE TABLE comments (
  id integer UNIQUE INDEX ,
  post_id integer,
  type char(255),
  body text
) 
go

CREATE TABLE authors (
  id integer UNIQUE INDEX ,
  name char(255) default NULL
) 
go

CREATE TABLE tasks (
  id integer UNIQUE INDEX DEFAULT _rowid,
  starting datetime,
  ending datetime
) 
go
CREATE PRIMARY KEY tasks (id) 
go

CREATE TABLE categories (
  id integer UNIQUE INDEX ,
  name char(255),
  type char(255)
) 
go

CREATE TABLE categories_posts (
  category_id integer NOT NULL,
  post_id integer NOT NULL
) 
go

CREATE TABLE fk_test_has_pk (
  id INTEGER NOT NULL DEFAULT _rowid
) 
go
CREATE PRIMARY KEY fk_test_has_pk (id) 
go

CREATE TABLE fk_test_has_fk (
  id    INTEGER NOT NULL DEFAULT _rowid,
  fk_id INTEGER NOT NULL REFERENCES fk_test_has_pk.id
) 
go
CREATE PRIMARY KEY fk_test_has_fk (id) 
go

CREATE TABLE keyboards (
  key_number integer UNIQUE INDEX DEFAULT _rowid,
  name char(50)
) 
go
CREATE PRIMARY KEY keyboards (key_number) 
go

CREATE TABLE legacy_things (
  id INTEGER NOT NULL DEFAULT _rowid,
  tps_report_number INTEGER default NULL,
  version integer NOT NULL default 0
)
go
CREATE PRIMARY KEY legacy_things (id)
go

CREATE TABLE numeric_data (
  id INTEGER NOT NULL DEFAULT _rowid,
  bank_balance DECIMAL(10,2),
  big_bank_balance DECIMAL(15,2),
  world_population DECIMAL(10),
  my_house_population DECIMAL(2),
  decimal_number_with_default DECIMAL(3,2) DEFAULT 2.78
);
go
CREATE PRIMARY KEY numeric_data (id)
go