public
anonymous / gist:3713388
Created

Database Migration Files

  • Download Gist
gistfile1.rb
Ruby
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 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599
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

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.