-
Notifications
You must be signed in to change notification settings - Fork 0
/
migrations.rb
95 lines (86 loc) · 2.67 KB
/
migrations.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
class CreateVideoFileTable < ActiveRecord::Migration[7.1]
def up
unless ActiveRecord::Base.connection.table_exists? :video_files
create_table :video_files do |table|
table.string :name
table.string :path
table.string :duration
table.boolean :favourite
table.timestamps
table.index :id
table.index :favourite
end
end
end
def down
drop_table(:video_files) if ActiveRecord::Base.connection.table_exists?(:video_files)
end
end
class CreateVideoPlaylistTable < ActiveRecord::Migration[7.1]
def up
unless ActiveRecord::Base.connection.table_exists? :video_playlists
create_table :video_playlists do |table|
table.string :name
end
end
end
def down
drop_table(:video_playlists) if ActiveRecord::Base.connection.table_exists?(:video_playlists)
end
end
class CreateVideoPlaylistVideoFilesTable < ActiveRecord::Migration[7.1]
def up
unless ActiveRecord::Base.connection.table_exists? :video_playlist_video_files
create_table :video_playlist_video_files do |t|
t.references :video_playlist, foreign_key: true
t.references :video_file, foreign_key: true
end
end
end
def down
drop_table(:video_playlist_video_files) if ActiveRecord::Base.connection.table_exists?(:video_playlist_video_files)
end
end
class CreateMusicFileTable < ActiveRecord::Migration[7.1]
def up
unless ActiveRecord::Base.connection.table_exists? :music_files
create_table :music_files do |table|
table.string :name
table.string :path
table.string :duration
table.boolean :favourite
table.timestamps
table.index :id
table.index :favourite
end
end
end
def down
drop_table(:music_files) if ActiveRecord::Base.connection.table_exists?(:music_files)
end
end
class CreateMusicPlayListTable < ActiveRecord::Migration[7.1]
def up
unless ActiveRecord::Base.connection.table_exists? :music_playlists
create_table :music_playlists do |table|
table.string :name
end
end
end
def down
drop_table(:music_playlists) if ActiveRecord::Base.connection.table_exists?(:music_playlists)
end
end
class CreateMusicPlaylistMusicFilesTable < ActiveRecord::Migration[7.1]
def up
unless ActiveRecord::Base.connection.table_exists? :music_playlist_music_files
create_table :music_playlist_music_files do |t|
t.references :music_playlist, foreign_key: true
t.references :music_file, foreign_key: true
end
end
end
def down
drop_table(:music_playlist_music_files) if ActiveRecord::Base.connection.table_exists?(:music_playlist_music_files)
end
end