This repository has been archived by the owner on Jul 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
20080915155611_initial_pb_core_database.rb
262 lines (228 loc) · 7.16 KB
/
20080915155611_initial_pb_core_database.rb
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
class InitialPbCoreDatabase < ActiveRecord::Migration
def self.up
create_table "assets" do |t|
t.timestamps
end
create_table "identifiers" do |t|
t.integer :asset_id
t.string :identifier, :null => false
t.integer :identifier_source_id
t.timestamps
end
add_index :identifiers, :asset_id
add_index :identifiers, [:identifier, :identifier_source_id]
create_table "identifier_sources" do |t|
t.column :name, :text, :null => false
t.timestamps
end
create_table "titles" do |t|
t.integer :asset_id
t.text :title, :null => false
t.integer :title_type_id
t.timestamps
end
add_index :titles, :asset_id
add_index :titles, :title_type_id
create_table "title_types" do |t|
t.column :name, :string, :null => false
t.column :category_id, :int
end
add_index :title_types, :name
create_table "title_type_categories" do |t|
t.column :name, :string, :null => false
end
create_table "subjects" do |t|
t.integer :asset_id
t.text :subject
t.text :subject_authority
t.timestamps
end
add_index :subjects, :asset_id
create_table "descriptions" do |t|
t.integer :asset_id
t.text :description, :null => false
t.integer :description_type_id
t.timestamps
end
add_index :descriptions, :asset_id
create_table "description_types" do |t|
t.column :name, :string
end
add_index :description_types, :name
create_table :genres do |t|
t.integer :asset_id
t.text :genre, :null => false
t.text :genre_authority_used
t.timestamps
end
add_index :genres, :asset_id
create_table :relations do |t|
t.integer :asset_id
t.integer :relation_type_id
t.string :relation_identifier
t.timestamps
end
add_index :relations, :asset_id
add_index :relations, :relation_identifier
create_table :relation_types do |t|
t.text :name, :null => false
end
create_table :coverages do |t|
t.integer :asset_id
t.text :coverage, :null => false
t.string :coverage_type, :null => false # 'spatial' or 'temporal'
t.timestamps
end
create_table :audience_levels do |t|
t.string :name, :null => false
end
create_table :assets_audience_levels, :id => false do |t|
t.integer :asset_id
t.integer :audience_level_id
end
add_index :assets_audience_levels, :asset_id
create_table :audience_ratings do |t|
t.string :name, :null => false
end
create_table :assets_audience_ratings, :id => false do |t|
t.integer :asset_id
t.integer :audience_rating_id
end
add_index :assets_audience_ratings, :asset_id
create_table :creators do |t|
t.integer :asset_id
t.text :creator, :null => false
t.integer :creator_role_id
t.timestamps
end
add_index :creators, :asset_id
create_table :creator_roles do |t|
t.string :name, :null => false
end
add_index :creator_roles, :name
create_table :contributors do |t|
t.integer :asset_id
t.text :contributor, :null => false
t.integer :contributor_role_id
t.timestamps
end
add_index :contributors, :asset_id
create_table :contributor_roles do |t|
t.string :name, :null => false
end
add_index :contributor_roles, :name
create_table :publishers do |t|
t.integer :asset_id
t.text :publisher, :null => false
t.integer :publisher_role_id
t.timestamps
end
add_index :publishers, :asset_id
create_table :publisher_roles do |t|
t.string :name, :null => false
end
add_index :publisher_roles, :name
create_table :rights_summaries do |t|
t.integer :asset_id
t.text :rights_summary, :null => false
t.timestamps
end
add_index :rights_summaries, :asset_id
create_table :instantiations do |t|
t.integer :asset_id
t.string :date_created
t.string :date_issued
t.integer :format_id
t.text :format_location, :null => false
t.integer :format_media_type
t.integer :format_generation_id
t.string :format_file_size
t.string :format_time_start
t.string :format_duration
t.string :format_data_rate
t.integer :format_color_id
t.text :format_tracks
t.text :format_channel_configuration
t.string :language
t.text :alternative_modes
t.timestamps
end
add_index :instantiations, :asset_id
create_table :format_ids do |t|
t.integer :instantiation_id
t.text :format_identifier, :null => false
t.text :format_identifier_source
t.timestamps
end
add_index :format_ids, :instantiation_id
create_table :formats do |t|
t.string :type, :null => false # STI
t.string :name, :null => false
end
add_index :formats, [:type, :name]
create_table :format_media_types do |t|
t.string :name, :null => false
end
add_index :format_media_types, :name
create_table :format_generations do |t|
t.string :name, :null => false
end
add_index :format_generations, :name
create_table :format_colors do |t|
t.string :name, :null => false
end
create_table :essence_tracks do |t|
t.integer :instantiation_id
# these are not documented yet...
# maybe some should eventually be lookup tables...
t.text :essence_track_type
t.text :essence_track_identifier
t.text :essence_track_identifier_source
t.text :essence_track_standard
t.text :essence_track_encoding
t.text :essence_track_data_rate
t.text :essence_track_time_start
t.text :essence_track_duration
t.text :essence_track_bit_depth
t.text :essence_track_sampling_rate
t.text :essence_track_frame_size
t.text :essence_track_aspect_ratio
t.text :essence_track_frame_rate
t.text :essence_track_language
t.text :essence_track_annotation
end
add_index :essence_tracks, :instantiation_id
create_table :date_availables do |t|
t.integer :instantiation_id
t.string :date_available_start
t.string :date_available_end
end
add_index :date_availables, :instantiation_id
create_table :annotation do |t|
t.integer :instantiation_id
t.text :annotation
end
add_index :annotation, :instantiation_id
create_table :extensions do |t|
t.integer :asset_id
t.text :extension
t.text :extension_authority_used
end
add_index :extensions, :asset_id
end
def self.down
[
:annotation, :assets, :assets_audience_levels, :assets_audience_ratings,
:audience_levels, :audience_ratings, :contributor_roles, :contributors,
:coverages, :creator_roles, :creators, :date_availables,
:description_types, :descriptions, :essence_tracks, :extensions,
:format_colors, :format_generations, :format_ids, :format_media_types,
:formats, :genres, :identifier_sources, :identifiers, :instantiations,
:publisher_roles, :publishers, :relation_types, :relations,
:rights_summaries, :subjects, :title_type_categories, :title_types,
:titles
].each do |t|
drop_table t
end
end
end