1
|
class CreateDockerImages < ActiveRecord::Migration
|
2
|
def up
|
3
|
create_table :docker_images do |t|
|
4
|
t.string :image_id
|
5
|
t.integer :size
|
6
|
t.timestamps
|
7
|
end
|
8
|
|
9
|
create_table :docker_tags do |t|
|
10
|
t.string :tag
|
11
|
t.references :docker_image, :null => false
|
12
|
t.timestamps
|
13
|
end
|
14
|
add_foreign_key :docker_tags, :docker_images,
|
15
|
:column => :docker_image_id
|
16
|
|
17
|
remove_column :containers, :image
|
18
|
remove_column :containers, :tag
|
19
|
add_column :containers, :docker_image_id, :integer
|
20
|
add_column :containers, :docker_tag_id, :integer
|
21
|
add_foreign_key :containers, :docker_images,
|
22
|
:column => :docker_image_id
|
23
|
add_foreign_key :containers, :docker_tags,
|
24
|
:column => :docker_tag_id
|
25
|
end
|
26
|
|
27
|
def down
|
28
|
drop_table :docker_images
|
29
|
drop_table :docker_tags
|
30
|
|
31
|
add_column :containers, :image, :string
|
32
|
add_column :containers, :tag, :string
|
33
|
remove_column :containers, :docker_image_id
|
34
|
remove_column :containers, :docker_tag_id
|
35
|
end
|
36
|
end
|