Save track files in new Sound model:

* Consolidate migrations
* Add Sound model. Each sound can belong to a track and contains
  informations about one sound file.
This commit is contained in:
Thibault Jouan
2011-09-15 21:08:24 +00:00
parent f49a5a3f67
commit 27550fd14e
26 changed files with 265 additions and 216 deletions

View File

@@ -1,13 +0,0 @@
class CreatePlaylists < ActiveRecord::Migration
def self.up
create_table :playlists do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :playlists
end
end

View File

@@ -1,13 +0,0 @@
class CreateTracks < ActiveRecord::Migration
def self.up
create_table :tracks do |t|
t.string :name
t.timestamps
end
end
def self.down
drop_table :tracks
end
end

View File

@@ -1,9 +0,0 @@
class AddMimeTypeFieldToTracks < ActiveRecord::Migration
def self.up
add_column :tracks, :mime_type, :string
end
def self.down
remove_column :tracks, :mime_type
end
end

View File

@@ -1,9 +0,0 @@
class AddSha256FieldToTracks < ActiveRecord::Migration
def self.up
add_column :tracks, :sha256, :string
end
def self.down
remove_column :tracks, :sha256
end
end

View File

@@ -1,16 +0,0 @@
class AddSessionsTable < ActiveRecord::Migration
def self.up
create_table :sessions do |t|
t.string :session_id, :null => false
t.text :data
t.timestamps
end
add_index :sessions, :session_id
add_index :sessions, :updated_at
end
def self.down
drop_table :sessions
end
end

View File

@@ -1,14 +0,0 @@
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.string :email
t.string :password
t.timestamps
end
end
def self.down
drop_table :users
end
end

View File

@@ -1,11 +0,0 @@
class AddPasswordHashToUsers < ActiveRecord::Migration
def self.up
add_column :users, :password_hash, :string
remove_column :users, :password
end
def self.down
remove_column :users, :password_hash
add_column :users, :password, :string
end
end

View File

@@ -1,9 +0,0 @@
class AddUserIdToPlaylists < ActiveRecord::Migration
def self.up
add_column :playlists, :user_id, :integer
end
def self.down
remove_column :playlists, :user_id
end
end

View File

@@ -1,9 +0,0 @@
class AddEmailUniqueIndexToUsers < ActiveRecord::Migration
def self.up
add_index :users, :email, :unique => true
end
def self.down
drop_index :users, :email
end
end

View File

@@ -0,0 +1,48 @@
class InitialSchema < ActiveRecord::Migration
def up
create_table :playlists do |t|
t.integer :user_id
t.string :name
t.timestamps
end
create_table :sessions do |t|
t.string :session_id, :null => false
t.text :data
t.timestamps
end
add_index :sessions, :session_id
add_index :sessions, :updated_at
create_table :tracks do |t|
t.string :name
t.timestamps
end
create_table :users do |t|
t.string :email
t.string :password_hash
t.timestamps
end
add_index :users, :email, :unique => true
end
def down
drop_index :sessions, :session_id
drop_index :sessions, :updated_at
drop_index :users, :email
drop_table :playlists
drop_table :sessions
drop_table :tracks
drop_table :users
end
end

View File

@@ -0,0 +1,15 @@
class CreateSounds < ActiveRecord::Migration
def up
create_table :sounds do |t|
t.integer :track_id
t.string :sha256
t.string :mime_type
t.timestamps
end
end
def down
drop_table :sounds
end
end

View File

@@ -10,13 +10,13 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20110913195421) do
ActiveRecord::Schema.define(:version => 20110916003929) do
create_table "playlists", :force => true do |t|
t.integer "user_id"
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
t.integer "user_id"
end
create_table "sessions", :force => true do |t|
@@ -29,19 +29,25 @@ ActiveRecord::Schema.define(:version => 20110913195421) do
add_index "sessions", ["session_id"], :name => "index_sessions_on_session_id"
add_index "sessions", ["updated_at"], :name => "index_sessions_on_updated_at"
create_table "sounds", :force => true do |t|
t.integer "track_id"
t.string "sha256"
t.string "mime_type"
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "tracks", :force => true do |t|
t.string "name"
t.datetime "created_at"
t.datetime "updated_at"
t.string "mime_type"
t.string "sha256"
end
create_table "users", :force => true do |t|
t.string "email"
t.string "password_hash"
t.datetime "created_at"
t.datetime "updated_at"
t.string "password_hash"
end
add_index "users", ["email"], :name => "index_users_on_email", :unique => true