Created
September 13, 2012 10:18
-
-
Save anonymous/3713388 to your computer and use it in GitHub Desktop.
Database Migration Files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CreateUsers < ActiveRecord::Migration | |
def change | |
create_table :users do |t| | |
t.string :artist_name | |
t.string :email_address | |
t.timestamps | |
end | |
end | |
end | |
class AddDeviseToUsers < ActiveRecord::Migration | |
def self.up | |
change_table(:users) do |t| | |
## Database authenticatable | |
t.string :email, :null => false, :default => "" | |
t.string :encrypted_password, :null => false, :default => "" | |
## Recoverable | |
t.string :reset_password_token | |
t.datetime :reset_password_sent_at | |
## Rememberable | |
t.datetime :remember_created_at | |
## Trackable | |
t.integer :sign_in_count, :default => 0 | |
t.datetime :current_sign_in_at | |
t.datetime :last_sign_in_at | |
t.string :current_sign_in_ip | |
t.string :last_sign_in_ip | |
## Encryptable | |
# t.string :password_salt | |
## Confirmable | |
# t.string :confirmation_token | |
# t.datetime :confirmed_at | |
# t.datetime :confirmation_sent_at | |
# t.string :unconfirmed_email # Only if using reconfirmable | |
## Lockable | |
# t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts | |
# t.string :unlock_token # Only if unlock strategy is :email or :both | |
# t.datetime :locked_at | |
## Token authenticatable | |
# t.string :authentication_token | |
# Uncomment below if timestamps were not included in your original model. | |
# t.timestamps | |
end | |
add_index :users, :email, :unique => true | |
add_index :users, :reset_password_token, :unique => true | |
# add_index :users, :confirmation_token, :unique => true | |
# add_index :users, :unlock_token, :unique => true | |
# add_index :users, :authentication_token, :unique => true | |
end | |
def self.down | |
# By default, we don't want to make any assumption about how to roll back a migration when your | |
# model already existed. Please edit below which fields you would like to remove in this migration. | |
raise ActiveRecord::IrreversibleMigration | |
end | |
end | |
class AddRoleToUser < ActiveRecord::Migration | |
def change | |
add_column :users, :role, :string | |
end | |
end | |
class DeviseCreateAdminUsers < ActiveRecord::Migration | |
def change | |
create_table(:admin_users) do |t| | |
## Database authenticatable | |
t.string :email, :null => false, :default => "" | |
t.string :encrypted_password, :null => false, :default => "" | |
## Recoverable | |
t.string :reset_password_token | |
t.datetime :reset_password_sent_at | |
## Rememberable | |
t.datetime :remember_created_at | |
## Trackable | |
t.integer :sign_in_count, :default => 0 | |
t.datetime :current_sign_in_at | |
t.datetime :last_sign_in_at | |
t.string :current_sign_in_ip | |
t.string :last_sign_in_ip | |
## Encryptable | |
# t.string :password_salt | |
## Confirmable | |
# t.string :confirmation_token | |
# t.datetime :confirmed_at | |
# t.datetime :confirmation_sent_at | |
# t.string :unconfirmed_email # Only if using reconfirmable | |
## Lockable | |
# t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts | |
# t.string :unlock_token # Only if unlock strategy is :email or :both | |
# t.datetime :locked_at | |
## Token authenticatable | |
# t.string :authentication_token | |
t.timestamps | |
end | |
# Create a default user | |
AdminUser.create!(:email => 'admin@example.com', :password => 'password', :password_confirmation => 'password') | |
add_index :admin_users, :email, :unique => true | |
add_index :admin_users, :reset_password_token, :unique => true | |
# add_index :admin_users, :confirmation_token, :unique => true | |
# add_index :admin_users, :unlock_token, :unique => true | |
# add_index :admin_users, :authentication_token, :unique => true | |
end | |
end | |
class CreateAdminNotes < ActiveRecord::Migration | |
def self.up | |
create_table :admin_notes do |t| | |
t.references :resource, :polymorphic => true, :null => false | |
t.references :admin_user, :polymorphic => true | |
t.text :body | |
t.timestamps | |
end | |
add_index :admin_notes, [:resource_type, :resource_id] | |
add_index :admin_notes, [:admin_user_type, :admin_user_id] | |
end | |
def self.down | |
drop_table :admin_notes | |
end | |
end | |
class MoveAdminNotesToComments < ActiveRecord::Migration | |
def self.up | |
remove_index :admin_notes, [:admin_user_type, :admin_user_id] | |
rename_table :admin_notes, :active_admin_comments | |
rename_column :active_admin_comments, :admin_user_type, :author_type | |
rename_column :active_admin_comments, :admin_user_id, :author_id | |
add_column :active_admin_comments, :namespace, :string | |
add_index :active_admin_comments, [:namespace] | |
add_index :active_admin_comments, [:author_type, :author_id] | |
# Update all the existing comments to the default namespace | |
say "Updating any existing comments to the #{ActiveAdmin.application.default_namespace} namespace." | |
execute "UPDATE active_admin_comments SET namespace='#{ActiveAdmin.application.default_namespace}'" | |
end | |
def self.down | |
remove_index :active_admin_comments, :column => [:author_type, :author_id] | |
remove_index :active_admin_comments, :column => [:namespace] | |
remove_column :active_admin_comments, :namespace | |
rename_column :active_admin_comments, :author_id, :admin_user_id | |
rename_column :active_admin_comments, :author_type, :admin_user_type | |
rename_table :active_admin_comments, :admin_notes | |
add_index :admin_notes, [:admin_user_type, :admin_user_id] | |
end | |
end | |
class CreateThemes < ActiveRecord::Migration | |
def change | |
create_table :themes do |t| | |
t.string :name | |
t.string :folder | |
t.timestamps | |
end | |
end | |
end | |
class CreateFreeSounds < ActiveRecord::Migration | |
def change | |
create_table :free_sounds do |t| | |
t.integer :theme_id | |
t.text :name | |
t.text :snippet | |
t.timestamps | |
end | |
end | |
end | |
class CreateTracks < ActiveRecord::Migration | |
def change | |
create_table :tracks do |t| | |
t.integer :theme_id | |
t.integer :user_id | |
t.boolean :live_instruments | |
t.boolean :vst | |
t.boolean :samples | |
t.boolean :midi | |
t.boolean :vocal | |
t.integer :wallpaper_id | |
t.timestamps | |
end | |
end | |
end | |
class CreateWallpapers < ActiveRecord::Migration | |
def change | |
create_table :wallpapers do |t| | |
t.integer :theme_id | |
t.string :path | |
t.timestamps | |
end | |
end | |
end | |
class AddDescriptionToTrack < ActiveRecord::Migration | |
def change | |
add_column :tracks, :description, :text | |
end | |
end | |
class AddAudioFileToTrack < ActiveRecord::Migration | |
def self.up | |
change_table :tracks do |t| | |
t.has_attached_file :audio_file | |
end | |
end | |
def self.down | |
drop_attached_file :tracks, :audio_file | |
end | |
end | |
class AddTitleToTrack < ActiveRecord::Migration | |
def change | |
add_column :tracks, :title, :string | |
end | |
end | |
class CreateSettings < ActiveRecord::Migration | |
def change | |
create_table :settings do |t| | |
t.string :key | |
t.string :value | |
t.timestamps | |
end | |
end | |
end | |
class AddUserIdToTheme < ActiveRecord::Migration | |
def change | |
add_column :themes, :user_id, :integer | |
end | |
end | |
class AddPlaycountToTrack < ActiveRecord::Migration | |
def change | |
add_column :tracks, :playcount, :integer | |
end | |
end | |
class AddStatusToTheme < ActiveRecord::Migration | |
def change | |
add_column :themes, :status, :integer | |
end | |
end | |
class AddVotesToTheme < ActiveRecord::Migration | |
def change | |
add_column :themes, :votes, :integer | |
end | |
end | |
class CreateVotes < ActiveRecord::Migration | |
def change | |
create_table :votes do |t| | |
t.integer :theme_id | |
t.integer :user_id | |
t.timestamps | |
end | |
end | |
end | |
class RenameVotesToVoteCount < ActiveRecord::Migration | |
def up | |
rename_column :themes, :votes, :vote_count | |
end | |
def down | |
rename_column :themes, :vote_count, :votes | |
end | |
end | |
class AddProfileToUser < ActiveRecord::Migration | |
def change | |
add_column :users, :town, :string | |
add_column :users, :bio, :text | |
add_column :users, :website, :string | |
add_column :users, :facebook, :string | |
add_column :users, :soudclou, :string | |
end | |
end | |
class RenameSoundClou < ActiveRecord::Migration | |
def up | |
rename_column :users, :soudclou, :soundcloud | |
end | |
def down | |
rename_column :users, :soundcloud, :soudclou | |
end | |
end | |
class AddAvatarToUser < ActiveRecord::Migration | |
def self.up | |
change_table :users do |t| | |
t.has_attached_file :avatar | |
end | |
end | |
def self.down | |
drop_attached_file :users, :avatar | |
end | |
end | |
class CreateFavourites < ActiveRecord::Migration | |
def change | |
create_table :favourites do |t| | |
t.integer :track_id | |
t.integer :user_id | |
t.timestamps | |
end | |
end | |
end | |
class AddDownloadableToTrack < ActiveRecord::Migration | |
def change | |
add_column :tracks, :downloadable, :boolean, :default => :false | |
end | |
end | |
class CreateRatings < ActiveRecord::Migration | |
def change | |
create_table :ratings do |t| | |
t.integer :track_id | |
t.integer :user_id | |
t.integer :score | |
t.timestamps | |
end | |
end | |
end | |
class Addconfirmable < ActiveRecord::Migration | |
def up | |
change_table(:users) do |t| | |
t.confirmable | |
end | |
end | |
def down | |
end | |
end | |
class Addreconfirmable < ActiveRecord::Migration | |
def up | |
change_table(:users) do |t| | |
t.reconfirmable | |
end | |
end | |
def down | |
end | |
end | |
class AddLicenseToTrack < ActiveRecord::Migration | |
def change | |
add_column :tracks, :license, :string | |
add_column :tracks, :license_url, :string | |
add_column :tracks, :license_name, :string | |
end | |
end | |
class AddScoreToTrack < ActiveRecord::Migration | |
def change | |
add_column :tracks, :score, :float | |
end | |
end | |
class AddBackgroundToTheme < ActiveRecord::Migration | |
def self.up | |
change_table :themes do |t| | |
t.has_attached_file :background | |
end | |
end | |
def self.down | |
drop_attached_file :themes, :background | |
end | |
end | |
class CreateStaticContents < ActiveRecord::Migration | |
def change | |
create_table :static_contents do |t| | |
t.string :title | |
t.text :content | |
t.timestamps | |
end | |
end | |
end | |
class CreateThemecolors < ActiveRecord::Migration | |
def change | |
create_table :themecolors do |t| | |
t.integer :theme_id | |
t.integer :user_id | |
t.string :color | |
t.text :description | |
t.timestamps | |
end | |
end | |
end | |
class CreateNewsItems < ActiveRecord::Migration | |
def change | |
create_table :news_items do |t| | |
t.string :title | |
t.text :contents | |
t.timestamps | |
end | |
end | |
end | |
class CreateVideos < ActiveRecord::Migration | |
def change | |
create_table :videos do |t| | |
t.string :name | |
t.text :html | |
t.text :description | |
t.timestamps | |
end | |
end | |
end | |
class CreateInfoPopups < ActiveRecord::Migration | |
def change | |
create_table :info_popups do |t| | |
t.string :identifier | |
t.string :page | |
t.string :title | |
t.text :content | |
t.timestamps | |
end | |
end | |
end | |
class AddCssidToInforPopup < ActiveRecord::Migration | |
def change | |
add_column :info_popups, :Cssid, :string | |
end | |
end | |
class ChangeCaseOfCssid < ActiveRecord::Migration | |
def up | |
rename_column :info_popups, :Cssid, :css_id | |
end | |
def down | |
rename_column :info_popups, :css_id, :Cssid | |
end | |
end | |
class RenameCssId < ActiveRecord::Migration | |
def up | |
rename_column :info_popups, :css_id, :the_css_id | |
end | |
def down | |
rename_column :info_popups, :the_css_id, :css_id | |
end | |
end | |
class RenametheCssId < ActiveRecord::Migration | |
def up | |
rename_column :info_popups, :the_css_id, :css_identifier | |
end | |
def down | |
rename_column :info_popups, :css_identifier,:the_css_id | |
end | |
end | |
class CreateSoundCloudTracks < ActiveRecord::Migration | |
def change | |
create_table :sound_cloud_tracks do |t| | |
t.integer :user_id | |
t.string :url1 | |
t.string :url2 | |
t.string :url3 | |
t.timestamps | |
end | |
end | |
end | |
class AddOverrideLinkToTheme < ActiveRecord::Migration | |
def change | |
add_column :themes, :override_link, :string | |
end | |
end | |
class AddTagsToTrack < ActiveRecord::Migration | |
def change | |
add_column :tracks, :tags, :string | |
end | |
end | |
class AddOutputFilePathToTrack < ActiveRecord::Migration | |
def change | |
add_column :tracks, :output_file_path, :string | |
end | |
end | |
class AddMainTranscodeReadyToTrack < ActiveRecord::Migration | |
def change | |
add_column :tracks, :main_transcode_ready, :boolean | |
end | |
end | |
class CreateBackgroundImages < ActiveRecord::Migration | |
def change | |
create_table :background_images do |t| | |
t.integer :theme_id | |
t.has_attached_file :image | |
t.timestamps | |
end | |
end | |
end | |
class AddSlugToUsers < ActiveRecord::Migration | |
def change | |
add_column :users, :slug, :string | |
add_index :users, :slug | |
end | |
end | |
class AddSlugToThemes < ActiveRecord::Migration | |
def change | |
add_column :themes, :slug, :string | |
add_index :themes, :slug | |
end | |
end | |
class AddUniqueToTracks < ActiveRecord::Migration | |
def change | |
add_column :tracks, :unique, :boolean | |
end | |
end | |
class RenameTracksUniqueToUniqueToSoundshoots < ActiveRecord::Migration | |
def up | |
rename_column :tracks, :unique, :unique_to_soundshoots | |
end | |
def down | |
rename_column :tracks, :unique_to_soundshoots, :unique | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment