Added Sequel migrations and models for videos and channels; Fixed database name in Rakefile and defaults config file
This commit is contained in:
18
db/migrations/0001_add_channels_table.rb
Normal file
18
db/migrations/0001_add_channels_table.rb
Normal file
@ -0,0 +1,18 @@
|
||||
Sequel.migration do
|
||||
|
||||
up do
|
||||
create_table(:channels) do
|
||||
primary_key :id
|
||||
String :name, null: false
|
||||
String :description
|
||||
DateTime :purchased_at
|
||||
DateTime :created_at, default: Sequel::CURRENT_TIMESTAMP
|
||||
DateTime :updated_at, default: Sequel::CURRENT_TIMESTAMP
|
||||
end
|
||||
end
|
||||
|
||||
down do
|
||||
drop_table(:channels)
|
||||
end
|
||||
|
||||
end
|
23
db/migrations/0002_add_videos_table.rb
Normal file
23
db/migrations/0002_add_videos_table.rb
Normal file
@ -0,0 +1,23 @@
|
||||
Sequel.migration do
|
||||
|
||||
up do
|
||||
create_table(:videos) do
|
||||
primary_key :id
|
||||
String :name, null: false
|
||||
String :description
|
||||
Integer :serial, null: false, unique: true
|
||||
DateTime :purchased_at
|
||||
DateTime :created_at, default: Sequel::CURRENT_TIMESTAMP
|
||||
DateTime :updated_at, default: Sequel::CURRENT_TIMESTAMP
|
||||
end
|
||||
|
||||
alter_table(:videos) do
|
||||
add_foreign_key :channel_id, :channels
|
||||
end
|
||||
end
|
||||
|
||||
down do
|
||||
drop_table(:videos)
|
||||
end
|
||||
|
||||
end
|
Reference in New Issue
Block a user