Initial commit

This commit is contained in:
Senad Uka
2020-05-31 22:38:19 +02:00
commit 858fafc3c5
1280 changed files with 65918 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
class PopulateReleasableTypeForFileInfos < ActiveRecord::DataMigration
def up
say "Populating FileInfo releasable type"
FileInfo.update_all(releasable_type: "AcquiredMediaRelease")
say "Done."
end
end

View File

@@ -0,0 +1,28 @@
class MoveMusicReleaseConfirmationsToAudioConfirmations < ActiveRecord::DataMigration
def up
say "Moving Music Release Confirmations to Audio Confirmations"
VideoReleaseConfirmation.where(releasable_type: "MusicRelease").find_each do |music_release_confirmation|
AudioConfirmation.create!(
video_id: music_release_confirmation.video_id,
channel: music_release_confirmation.channel,
timecode_in: music_release_confirmation.timecode_in,
timecode_out: music_release_confirmation.timecode_out,
duration: music_release_confirmation.duration,
source_file_name: music_release_confirmation.source_file_name,
clip_name: music_release_confirmation.clip_name,
description: music_release_confirmation.description,
time_elapsed: music_release_confirmation.time_elapsed,
music_type: music_release_confirmation.music_type,
music_category: music_release_confirmation.music_category,
composer_info: music_release_confirmation.releasable.composers.map { |composer| "#{composer.name}, #{composer.affiliation}, #{composer.percentage}%" }.join("|"),
publisher_info: music_release_confirmation.releasable.publishers.map { |publisher| "#{publisher.name}, #{publisher.affiliation}, #{publisher.percentage}%" }.join("|"),
catalog: "",
title: "",
time_elapsed: music_release_confirmation.time_elapsed,
)
end
say "Done."
end
end

View File

@@ -0,0 +1,9 @@
class RemoveMusicReleaseConfirmations < ActiveRecord::DataMigration
def up
say "Removing MusicReleaseConfirmations"
VideoReleaseConfirmation.where(releasable_type: "MusicRelease").destroy_all
say "Done."
end
end

View File

@@ -0,0 +1,9 @@
class UpdatePlanUidsToMeSuite < ActiveRecord::DataMigration
def up
say "Migrating Plan UIDs to all be me_suite"
Account.update_all(plan_uid: "me_suite")
say "Done."
end
end

View File

@@ -0,0 +1,17 @@
class SetGraphicTypeForGraphicElements < ActiveRecord::DataMigration
def up
say "Setting #graphic_type for GraphicElements.."
GraphicsElement.update_all(graphic_type: "Other")
say "Done."
end
def down
say "Unsetting #graphic_type for GraphicElements.."
GraphicsElement.update_all(graphic_type: nil)
say "Done."
end
end

View File

@@ -0,0 +1,22 @@
class SetTerritoryAndTermForAcquiredMediaReleases < ActiveRecord::DataMigration
def up
say "Setting AcquiredMediaRelease#term and #territory.."
AcquiredMediaRelease.find_each do |acquired_media_release|
acquired_media_release.update(
term: Term.find_by(label: acquired_media_release.term_old),
territory: Territory.find_by(label: acquired_media_release.territory_old),
)
end
say "Done."
end
def down
say "Un-setting AcquiredMediaRelease#term and #territory.."
AcquiredMediaRelease.update_all(term: nil, territory: nil)
say "Done."
end
end

View File

@@ -0,0 +1,32 @@
class ConvertReleasableNotesToCollection < ActiveRecord::DataMigration
RELEASABLE_TYPES = [
TalentRelease,
AppearanceRelease,
LocationRelease,
AcquiredMediaRelease,
MaterialRelease,
MusicRelease,
]
def up
RELEASABLE_TYPES.each { |type| convert_notes_to_collection_for(type) }
say "Done."
end
private
def convert_notes_to_collection_for(releasable_type)
say "Converting #{releasable_type}#notes to collection..."
releasable_type.where.not(notes_old: nil).find_each do |releasable|
content = releasable[:notes_old]
user = releasable.project.account.users.order(:created_at).first
Note.create(content: content, user: user, notable: releasable)
end
end
class Note < ActiveRecord::Base
belongs_to :user
belongs_to :notable, polymorphic: true
end
end

View File

@@ -0,0 +1,33 @@
# frozen_string_literal: true
class NewPermissionSystem < ActiveRecord::DataMigration
def up
say 'Creating AccountAuths and ProjectMemberships for existing Projects...'
User.all.each do |user|
next if user.account_id_old.nil?
role = user.role_old == 0 ? :associate : :account_manager
account = Account.find(user.account_id_old)
# Create a membership to the account for the user
AccountAuth.create(user: user, account: account, role: role)
# If the user is not an account manager, create a membership to each project in the account for the user
if role != :account_manager
account.projects.each do |project|
ProjectMembership.create!(project: project, user: user)
end
end
end
say 'Done.'
end
def down
say 'Destroying new permission system artifacts'
ProjectMembership.destroy_all
AccountAuth.destroy_all
say 'Done.'
end
end

View File

@@ -0,0 +1,13 @@
class ChangePermissionsCustomFolders < ActiveRecord::DataMigration
def up
say 'Changing permissions of custom folders for existing records...'
project_manager_directory_ids = Directory.where(permissions: "Account Managers Only").map(&:id)
account_manager_directory_ids = Directory.where(permissions: "Account Managers & Project Managers").map(&:id)
Directory.where(id: project_manager_directory_ids).update_all(permissions: "Account Managers & Project Managers")
Directory.where(id: account_manager_directory_ids).update_all(permissions: "Account Managers Only")
say 'Done'
end
end

View File

@@ -0,0 +1,17 @@
class MigrateInternalTags < ActiveRecord::DataMigration
def up
say 'Migrating tag context to internal tags list...'
ActsAsTaggableOn::Tagging.update_all(context: "internal_tags")
say 'Done'
end
def down
say 'Migrating tag context back to default tags list...'
ActsAsTaggableOn::Tagging.update_all(context: "tags")
say 'Done'
end
end

View File

@@ -0,0 +1,5 @@
class MakeContractTemplatesFeesValid < ActiveRecord::DataMigration
def up
ContractTemplate.where("fee_cents < 0 or fee_cents > 9999999999").update_all("fee_cents = 0")
end
end

View File

@@ -0,0 +1,17 @@
class MigratePersonNameFieldForAllReleases < ActiveRecord::DataMigration
RELEASES = ["AcquiredMediaRelease", "AppearanceRelease", "LocationRelease", "MaterialRelease", "MusicRelease", "TalentRelease"]
def up
say 'Migrating person name ...'
RELEASES.each do |release|
release.constantize.find_each do |record|
if record.person_name_old.present?
record.update(person_name: record.person_name_old)
end
end
end
say 'Done'
end
end

View File

@@ -0,0 +1,17 @@
class MigrateGuardianNameForAllReleases < ActiveRecord::DataMigration
RELEASES = ["AppearanceRelease", "TalentRelease"]
def up
say 'Migrating guardian name ...'
RELEASES.each do |release|
release.constantize.find_each do |record|
if record.guardian_name_old.present?
record.update(guardian_name: record.guardian_name_old)
end
end
end
say 'Done'
end
end

View File

@@ -0,0 +1,21 @@
class SetEmailForNotes < ActiveRecord::DataMigration
def up
say "Setting #email for Notes..."
Note.find_each do |note|
if note.user.present? && note.user.email.present?
note.update_column(:email, note.user.email)
end
end
say "Done."
end
def down
say "Unsetting #email for Notes..."
Note.update_all(email: nil)
say "Done."
end
end

View File

@@ -0,0 +1,7 @@
class GenerateTokensForExistingBroadcasts < ActiveRecord::DataMigration
def up
Broadcast.where(token: nil).each do |broadcast|
broadcast.regenerate_token
end
end
end

View File

@@ -0,0 +1,14 @@
# frozen_string_literal: true
class GiveNamesToImportedAppearanceReleases < ActiveRecord::DataMigration
def up
AppearanceRelease.where(person_first_name: nil).each do |ar|
contract_no = AppearanceRelease.random_contract_number.to_s
if ar.person_photo.attached?
ar.update(person_first_name: I18n.t('appearance_releases.shared.imported_appearance_release_headshot_name'), person_last_name: contract_no)
else
ar.update(person_first_name: I18n.t('appearance_releases.shared.imported_appearance_release_contract_name'), person_last_name: contract_no)
end
end
end
end

View File

@@ -0,0 +1,16 @@
class AssignZoomMeetingsToProjects < ActiveRecord::DataMigration
def up
ZoomMeeting.find_each do |zm|
if zm.respond_to?(:broadcast_id) && zm.broadcast_id.present?
broadcast = Broadcast.find_by(id: zm.broadcast_id)
if broadcast.present?
zm.update_column(:project_id, broadcast.project_id)
end
end
end
end
def down
ZoomMeeting.update_all(project_id: nil)
end
end

View File

@@ -0,0 +1,10 @@
class FixInvalidBroadcastStatuses < ActiveRecord::DataMigration
def up
say "Fixing invalid Broadcast#status..."
broadcasts_with_broken_statuses = Broadcast.where.not(status: Broadcast.statuses.values)
broadcasts_with_broken_statuses.update_all(status: nil)
say "Done."
end
end

View File

@@ -0,0 +1,26 @@
# This migration comes from active_storage (originally 20170806125915)
class CreateActiveStorageTables < ActiveRecord::Migration[5.2]
def change
create_table :active_storage_blobs do |t|
t.string :key, null: false
t.string :filename, null: false
t.string :content_type
t.text :metadata
t.bigint :byte_size, null: false
t.string :checksum, null: false
t.datetime :created_at, null: false
t.index [ :key ], unique: true
end
create_table :active_storage_attachments do |t|
t.string :name, null: false
t.references :record, null: false, polymorphic: true, index: false
t.references :blob, null: false
t.datetime :created_at, null: false
t.index [ :record_type, :record_id, :name, :blob_id ], name: "index_active_storage_attachments_uniqueness", unique: true
end
end
end

View File

@@ -0,0 +1,12 @@
class CreateUsers < ActiveRecord::Migration[5.2]
def change
create_table :users do |t|
t.string :email, null: false
t.string :password_digest, null: false
t.timestamps null: false
end
add_index :users, :email, unique: true
end
end

View File

@@ -0,0 +1,15 @@
class CreateProjects < ActiveRecord::Migration[5.2]
def change
create_table :projects do |t|
t.string :name, null: false
t.string :client_name
t.string :producer_name
t.string :producer_address
t.text :description
t.text :details
t.belongs_to :user, foreign_key: true, null: false
t.timestamps
end
end
end

View File

@@ -0,0 +1,13 @@
class CreateAppearanceReleases < ActiveRecord::Migration[5.2]
def change
create_table :appearance_releases do |t|
t.string :person_name, null: false
t.string :person_address, null: false
t.string :person_phone, null: false
t.string :person_ssn
t.belongs_to :project, foreign_key: true
t.timestamps
end
end
end

View File

@@ -0,0 +1,5 @@
class AddSampleToProjects < ActiveRecord::Migration[5.2]
def change
add_column :projects, :sample, :boolean, default: false
end
end

View File

@@ -0,0 +1,9 @@
class AddGuardianFieldsToAppearanceReleases < ActiveRecord::Migration[5.2]
def change
add_column :appearance_releases, :minor, :boolean, default: false
add_column :appearance_releases, :guardian_address, :string
add_column :appearance_releases, :guardian_name, :string
add_column :appearance_releases, :guardian_phone, :string
add_column :appearance_releases, :guardian_ssn, :string
end
end

View File

@@ -0,0 +1,43 @@
class AddEncryptedPersonSsnToAppearanceReleases < ActiveRecord::Migration[5.2]
def up
add_column :appearance_releases, :encrypted_person_ssn, :string
add_column :appearance_releases, :encrypted_person_ssn_iv, :string
migrate_data_up!
remove_column :appearance_releases, :person_ssn, :string
end
def down
add_column :appearance_releases, :person_ssn, :string
migrate_data_down!
remove_column :appearance_releases, :encrypted_person_ssn
remove_column :appearance_releases, :encrypted_person_ssn_iv
end
private
def migrate_data_up!
say "Encrypting person SSNs..."
AppearanceRelease.find_each do |appearance_release|
# Access the value of the attribute directly using hash syntax then use the accessor to encrypt it
appearance_release.update!(person_ssn: appearance_release[:person_ssn])
end
say "Done."
end
def migrate_data_down!
say "Decrypting person SSNs..."
AppearanceRelease.find_each do |appearance_release|
appearance_release[:person_ssn] = appearance_release.person_ssn
appearance_release.save!
end
say "Done."
end
end

View File

@@ -0,0 +1,5 @@
class AddHeadshotCollectionUidToProjects < ActiveRecord::Migration[5.2]
def change
add_column :projects, :headshot_collection_uid, :string
end
end

View File

@@ -0,0 +1,9 @@
class CreateVideos < ActiveRecord::Migration[5.2]
def change
create_table :videos do |t|
t.belongs_to :project, foreign_key: true
t.timestamps
end
end
end

View File

@@ -0,0 +1,6 @@
class AddAnalysisFieldsToVideos < ActiveRecord::Migration[5.2]
def change
add_column :videos, :analysis_uid, :string
add_column :videos, :analysis_status, :integer, default: 0
end
end

View File

@@ -0,0 +1,5 @@
class AddIndexForAnalysisUidToVideos < ActiveRecord::Migration[5.2]
def change
add_index :videos, :analysis_uid
end
end

View File

@@ -0,0 +1,5 @@
class AddNotesToAppearanceReleases < ActiveRecord::Migration[5.2]
def change
add_column :appearance_releases, :notes, :text
end
end

View File

@@ -0,0 +1,6 @@
class AddTeamNameToUsers < ActiveRecord::Migration[5.2]
def change
add_column :users, :team_name, :string
add_index :users, :team_name, unique: true
end
end

View File

@@ -0,0 +1,5 @@
class AddAnalysisStartedAtToVideos < ActiveRecord::Migration[5.2]
def change
add_column :videos, :analysis_started_at, :datetime
end
end

View File

@@ -0,0 +1,6 @@
class ChangeColumnNullForAppearanceReleases < ActiveRecord::Migration[5.2]
def change
change_column_null(:appearance_releases, :person_address, true)
change_column_null(:appearance_releases, :person_phone, true)
end
end

View File

@@ -0,0 +1,5 @@
class AddPersonEmailToAppearanceReleases < ActiveRecord::Migration[5.2]
def change
add_column :appearance_releases, :person_email, :string
end
end

View File

@@ -0,0 +1,5 @@
class AddLocaleToAppearanceReleases < ActiveRecord::Migration[5.2]
def change
add_column :appearance_releases, :locale, :string
end
end

View File

@@ -0,0 +1,36 @@
# This migration comes from acts_as_taggable_on_engine (originally 1)
if ActiveRecord.gem_version >= Gem::Version.new('5.0')
class ActsAsTaggableOnMigration < ActiveRecord::Migration[4.2]; end
else
class ActsAsTaggableOnMigration < ActiveRecord::Migration; end
end
ActsAsTaggableOnMigration.class_eval do
def self.up
create_table :tags do |t|
t.string :name
end
create_table :taggings do |t|
t.references :tag
# You should make sure that the column created is
# long enough to store the required class names.
t.references :taggable, polymorphic: true
t.references :tagger, polymorphic: true
# Limit is created to prevent MySQL error on index
# length for MyISAM table type: http://bit.ly/vgW2Ql
t.string :context, limit: 128
t.datetime :created_at
end
add_index :taggings, :tag_id
add_index :taggings, [:taggable_id, :taggable_type, :context]
end
def self.down
drop_table :taggings
drop_table :tags
end
end

View File

@@ -0,0 +1,26 @@
# This migration comes from acts_as_taggable_on_engine (originally 2)
if ActiveRecord.gem_version >= Gem::Version.new('5.0')
class AddMissingUniqueIndices < ActiveRecord::Migration[4.2]; end
else
class AddMissingUniqueIndices < ActiveRecord::Migration; end
end
AddMissingUniqueIndices.class_eval do
def self.up
add_index :tags, :name, unique: true
remove_index :taggings, :tag_id if index_exists?(:taggings, :tag_id)
remove_index :taggings, [:taggable_id, :taggable_type, :context]
add_index :taggings,
[:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, :tagger_type],
unique: true, name: 'taggings_idx'
end
def self.down
remove_index :tags, :name
remove_index :taggings, name: 'taggings_idx'
add_index :taggings, :tag_id unless index_exists?(:taggings, :tag_id)
add_index :taggings, [:taggable_id, :taggable_type, :context]
end
end

View File

@@ -0,0 +1,20 @@
# This migration comes from acts_as_taggable_on_engine (originally 3)
if ActiveRecord.gem_version >= Gem::Version.new('5.0')
class AddTaggingsCounterCacheToTags < ActiveRecord::Migration[4.2]; end
else
class AddTaggingsCounterCacheToTags < ActiveRecord::Migration; end
end
AddTaggingsCounterCacheToTags.class_eval do
def self.up
add_column :tags, :taggings_count, :integer, default: 0
ActsAsTaggableOn::Tag.reset_column_information
ActsAsTaggableOn::Tag.find_each do |tag|
ActsAsTaggableOn::Tag.reset_counters(tag.id, :taggings)
end
end
def self.down
remove_column :tags, :taggings_count
end
end

View File

@@ -0,0 +1,15 @@
# This migration comes from acts_as_taggable_on_engine (originally 4)
if ActiveRecord.gem_version >= Gem::Version.new('5.0')
class AddMissingTaggableIndex < ActiveRecord::Migration[4.2]; end
else
class AddMissingTaggableIndex < ActiveRecord::Migration; end
end
AddMissingTaggableIndex.class_eval do
def self.up
add_index :taggings, [:taggable_id, :taggable_type, :context]
end
def self.down
remove_index :taggings, [:taggable_id, :taggable_type, :context]
end
end

View File

@@ -0,0 +1,15 @@
# This migration comes from acts_as_taggable_on_engine (originally 5)
# This migration is added to circumvent issue #623 and have special characters
# work properly
if ActiveRecord.gem_version >= Gem::Version.new('5.0')
class ChangeCollationForTagNames < ActiveRecord::Migration[4.2]; end
else
class ChangeCollationForTagNames < ActiveRecord::Migration; end
end
ChangeCollationForTagNames.class_eval do
def up
if ActsAsTaggableOn::Utils.using_mysql?
execute("ALTER TABLE tags MODIFY name varchar(255) CHARACTER SET utf8 COLLATE utf8_bin;")
end
end
end

View File

@@ -0,0 +1,23 @@
# This migration comes from acts_as_taggable_on_engine (originally 6)
if ActiveRecord.gem_version >= Gem::Version.new('5.0')
class AddMissingIndexesOnTaggings < ActiveRecord::Migration[4.2]; end
else
class AddMissingIndexesOnTaggings < ActiveRecord::Migration; end
end
AddMissingIndexesOnTaggings.class_eval do
def change
add_index :taggings, :tag_id unless index_exists? :taggings, :tag_id
add_index :taggings, :taggable_id unless index_exists? :taggings, :taggable_id
add_index :taggings, :taggable_type unless index_exists? :taggings, :taggable_type
add_index :taggings, :tagger_id unless index_exists? :taggings, :tagger_id
add_index :taggings, :context unless index_exists? :taggings, :context
unless index_exists? :taggings, [:tagger_id, :tagger_type]
add_index :taggings, [:tagger_id, :tagger_type]
end
unless index_exists? :taggings, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy'
add_index :taggings, [:taggable_id, :taggable_type, :tagger_id, :context], name: 'taggings_idy'
end
end
end

View File

@@ -0,0 +1,10 @@
class CreateVideoAppearanceConfirmations < ActiveRecord::Migration[5.2]
def change
create_table :video_appearance_confirmations do |t|
t.belongs_to :video, foreign_key: true
t.belongs_to :appearance_release, foreign_key: true
t.timestamps
end
end
end

View File

@@ -0,0 +1,10 @@
class CreateBookmarks < ActiveRecord::Migration[5.2]
def change
create_table :bookmarks do |t|
t.belongs_to :video, foreign_key: true
t.string :time_elapsed
t.timestamps
end
end
end

View File

@@ -0,0 +1,10 @@
class CreateUnreleasedAppearances < ActiveRecord::Migration[5.2]
def change
create_table :unreleased_appearances do |t|
t.belongs_to :video, foreign_key: true
t.string :time_elapsed
t.timestamps
end
end
end

View File

@@ -0,0 +1,17 @@
class CreateAreaReleases < ActiveRecord::Migration[5.2]
def change
create_table :area_releases do |t|
t.belongs_to :project, foreign_key: true
t.string :name
t.string :address_street1
t.string :address_street2
t.string :address_city
t.string :address_state
t.string :address_zip
t.string :address_country
t.text :notes
t.timestamps
end
end
end

View File

@@ -0,0 +1,5 @@
class AddTimeElapsedToVideoAppearanceConfirmations < ActiveRecord::Migration[5.2]
def change
add_column :video_appearance_confirmations, :time_elapsed, :string
end
end

View File

@@ -0,0 +1,28 @@
class CreateLocationReleases < ActiveRecord::Migration[5.2]
def change
create_table :location_releases do |t|
t.belongs_to :project, foreign_key: true
t.string :name
t.string :address_street1
t.string :address_street2
t.string :address_city
t.string :address_state
t.string :address_zip
t.string :address_country
t.string :person_name
t.string :person_address_street1
t.string :person_address_street2
t.string :person_address_city
t.string :person_address_state
t.string :person_address_zip
t.string :person_address_country
t.string :person_phone
t.string :person_email
t.string :person_title
t.string :person_company
t.text :notes
t.timestamps
end
end
end

View File

@@ -0,0 +1,22 @@
class CreateMaterialReleases < ActiveRecord::Migration[5.2]
def change
create_table :material_releases do |t|
t.belongs_to :project, foreign_key: true
t.string :name
t.string :person_name
t.string :person_address_street1
t.string :person_address_street2
t.string :person_address_city
t.string :person_address_state
t.string :person_address_zip
t.string :person_address_country
t.string :person_phone
t.string :person_email
t.string :person_title
t.string :person_company
t.text :notes
t.timestamps
end
end
end

View File

@@ -0,0 +1,5 @@
class RenameVideoAppearanceConfirmations < ActiveRecord::Migration[5.2]
def change
rename_table :video_appearance_confirmations, :video_release_confirmations
end
end

View File

@@ -0,0 +1,8 @@
class MakeVideoReleaseConfirmationsPolymorphic < ActiveRecord::Migration[5.2]
def change
remove_foreign_key :video_release_confirmations, :appearance_releases
rename_column :video_release_confirmations, :appearance_release_id, :releasable_id
add_column :video_release_confirmations, :releasable_type, :string, after: :releasable_id
add_index :video_release_confirmations, [:releasable_id, :releasable_type], name: "index_video_release_confirmations_on_releasable_id_and_type"
end
end

View File

@@ -0,0 +1,5 @@
class AddNotesToBookmarks < ActiveRecord::Migration[5.2]
def change
add_column :bookmarks, :notes, :text
end
end

View File

@@ -0,0 +1,5 @@
class AddNotesToUnreleasedAppearances < ActiveRecord::Migration[5.2]
def change
add_column :unreleased_appearances, :notes, :text
end
end

View File

@@ -0,0 +1,5 @@
class AddTaggingStatusToAppearanceReleases < ActiveRecord::Migration[5.2]
def change
add_column :appearance_releases, :tagging_status, :integer, default: 0
end
end

View File

@@ -0,0 +1,5 @@
class AddTaggingStatusToLocationReleases < ActiveRecord::Migration[5.2]
def change
add_column :location_releases, :tagging_status, :integer, default: 0
end
end

View File

@@ -0,0 +1,5 @@
class AddTaggingStatusToMaterialReleases < ActiveRecord::Migration[5.2]
def change
add_column :material_releases, :tagging_status, :integer, default: 0
end
end

View File

@@ -0,0 +1,5 @@
class AddTaggingStatusToAreaReleases < ActiveRecord::Migration[5.2]
def change
add_column :area_releases, :tagging_status, :integer, default: 0
end
end

View File

@@ -0,0 +1,11 @@
class InstallPgContribPackages < ActiveRecord::Migration[5.2]
def up
execute "CREATE EXTENSION IF NOT EXISTS pg_trgm;"
execute "CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;"
end
def down
execute "DROP EXTENSION pg_trgm;"
execute "DROP EXTENSION fuzzystrmatch;"
end
end

View File

@@ -0,0 +1,19 @@
class AddPgSearchDmetaphoneSupportFunctions < ActiveRecord::Migration[5.2]
def self.up
say_with_time("Adding support functions for pg_search :dmetaphone") do
execute <<-'SQL'
CREATE OR REPLACE FUNCTION pg_search_dmetaphone(text) RETURNS text LANGUAGE SQL IMMUTABLE STRICT AS $function$
SELECT array_to_string(ARRAY(SELECT dmetaphone(unnest(regexp_split_to_array($1, E'\\s+')))), ' ')
$function$;
SQL
end
end
def self.down
say_with_time("Dropping support functions for pg_search :dmetaphone") do
execute <<-'SQL'
DROP FUNCTION pg_search_dmetaphone(text);
SQL
end
end
end

View File

@@ -0,0 +1,10 @@
class CreateImports < ActiveRecord::Migration[5.2]
def change
create_table :imports do |t|
t.belongs_to :project, foreign_key: true
t.integer :status, default: 0
t.timestamps
end
end
end

View File

@@ -0,0 +1,5 @@
class AddReleasableToImports < ActiveRecord::Migration[5.2]
def change
add_reference :imports, :releasable, polymorphic: true
end
end

View File

@@ -0,0 +1,13 @@
class CreateContractTemplates < ActiveRecord::Migration[5.2]
def change
create_table :contract_templates do |t|
t.belongs_to :project, foreign_key: true
t.string :name
t.text :body
t.text :guardian_clause
t.monetize :fee
t.timestamps
end
end
end

View File

@@ -0,0 +1,5 @@
class AddContractTemplateToAppearanceReleases < ActiveRecord::Migration[5.2]
def change
add_reference :appearance_releases, :contract_template, foreign_key: true
end
end

View File

@@ -0,0 +1,15 @@
# This migration comes from action_text (originally 201805281641)
class CreateActionTextTables < ActiveRecord::Migration[5.2]
def change
create_table :action_text_rich_texts do |t|
t.string :name, null: false
t.text :body, limit: 16777215
t.references :record, null: false, polymorphic: true, index: false
t.datetime :created_at, null: false
t.datetime :updated_at, null: false
t.index [ :record_type, :record_id, :name ], name: "index_action_text_rich_texts_uniqueness", unique: true
end
end
end

View File

@@ -0,0 +1,5 @@
class AddLocaleToLocationReleases < ActiveRecord::Migration[5.2]
def change
add_column :location_releases, :locale, :string
end
end

View File

@@ -0,0 +1,5 @@
class AddContractTemplateToLocationReleases < ActiveRecord::Migration[5.2]
def change
add_reference :location_releases, :contract_template, foreign_key: true
end
end

View File

@@ -0,0 +1,5 @@
class AddReleaseTypeToContractTemplates < ActiveRecord::Migration[5.2]
def change
add_column :contract_templates, :release_type, :string
end
end

View File

@@ -0,0 +1,5 @@
class AddContractTemplateToMaterialReleases < ActiveRecord::Migration[5.2]
def change
add_reference :material_releases, :contract_template, foreign_key: true
end
end

View File

@@ -0,0 +1,5 @@
class AddLocaleToMaterialReleases < ActiveRecord::Migration[5.2]
def change
add_column :material_releases, :locale, :string
end
end

View File

@@ -0,0 +1,5 @@
class AddLocaleToAreaReleases < ActiveRecord::Migration[5.2]
def change
add_column :area_releases, :locale, :string
end
end

View File

@@ -0,0 +1,5 @@
class AddContractTemplateToAreaReleases < ActiveRecord::Migration[5.2]
def change
add_reference :area_releases, :contract_template, foreign_key: true
end
end

View File

@@ -0,0 +1,5 @@
class AddAdminToUsers < ActiveRecord::Migration[5.2]
def change
add_column :users, :admin, :boolean, default: false
end
end

View File

@@ -0,0 +1,5 @@
class AddPlanUidToUsers < ActiveRecord::Migration[5.2]
def change
add_column :users, :plan_uid, :string
end
end

View File

@@ -0,0 +1,12 @@
class CreateAccounts < ActiveRecord::Migration[5.2]
def change
create_table :accounts do |t|
t.string :name
t.string :slug
t.string :plan_uid
t.timestamps
end
add_index :accounts, :slug, unique: true
end
end

View File

@@ -0,0 +1,47 @@
class AddAccountToUsers < ActiveRecord::Migration[5.2]
def up
add_reference :users, :account, foreign_key: true
migrate_data_up
remove_column :users, :team_name, :string
end
def down
add_column :users, :team_name, :string
migrate_user_data_down
remove_reference :users, :account
migrate_account_data_down
end
private
def migrate_data_up
say "Creating Accounts.."
User.find_each do |user|
account = Account.new(name: user.team_name.titleize, slug: user.team_name)
user.update!(account: account)
end
say "Done."
end
def migrate_user_data_down
say "Updating Users.."
User.find_each do |user|
user.update!(team_name: user.account.slug)
end
say "Done."
end
def migrate_account_data_down
say "Destroying Accounts.."
Account.delete_all
say "Done."
end
end

View File

@@ -0,0 +1,42 @@
class AddAccountToProjects < ActiveRecord::Migration[5.2]
def up
add_reference :projects, :account, foreign_key: true
migrate_data_up
remove_reference :projects, :user
end
def down
add_reference :projects, :user, foreign_key: true
migrate_data_down
remove_reference :projects, :account
end
private
class Project < ActiveRecord::Base
belongs_to :account
belongs_to :user
end
def migrate_data_up
say "Setting Project#account.."
Project.reset_column_information
Project.find_each do |project|
project.update!(account: project.user.account)
end
say "Done."
end
def migrate_data_down
say "Setting Project#user.."
Project.reset_column_information
Project.find_each do |project|
project.update!(user: project.account.users.first)
end
say "Done."
end
end

View File

@@ -0,0 +1,6 @@
class AddPasswordResetTokenToUsers < ActiveRecord::Migration[5.2]
def change
add_column :users, :password_reset_token, :string
add_index :users, :password_reset_token, unique: true
end
end

View File

@@ -0,0 +1,35 @@
class CreateTalentReleases < ActiveRecord::Migration[5.2]
def change
create_table :talent_releases do |t|
t.belongs_to :project, foreign_key: true
t.belongs_to :contract_template, foreign_key: true
t.string :person_name
t.string :person_address_street1
t.string :person_address_street2
t.string :person_address_city
t.string :person_address_state
t.string :person_address_zip
t.string :person_address_country
t.string :person_phone
t.string :person_email
t.string :encrypted_person_ssn
t.string :encrypted_person_ssn_iv
t.string :guardian_name
t.string :guardian_address_street1
t.string :guardian_address_street2
t.string :guardian_address_city
t.string :guardian_address_state
t.string :guardian_address_zip
t.string :guardian_address_country
t.string :guardian_phone
t.string :guardian_email
t.string :encrypted_guardian_ssn
t.string :encrypted_guardian_ssn_iv
t.boolean :minor, default: false
t.string :locale
t.text :notes
t.timestamps
end
end
end

View File

@@ -0,0 +1,5 @@
class AddTaggingStatusToTalentReleases < ActiveRecord::Migration[5.2]
def change
add_column :talent_releases, :tagging_status, :integer, default: 0
end
end

View File

@@ -0,0 +1,6 @@
class AddNameAndNumberToVideos < ActiveRecord::Migration[5.2]
def change
add_column :videos, :name, :string
add_column :videos, :number, :string
end
end

View File

@@ -0,0 +1,25 @@
class CreateAcquiredMediaReleases < ActiveRecord::Migration[5.2]
def change
create_table :acquired_media_releases do |t|
t.references :project, foreign_key: true
t.references :contract_template, foreign_key: true
t.string :locale
t.text :notes
t.integer :tagging_status, default: 0
t.string :name
t.string :person_name
t.string :person_address_street1
t.string :person_address_street2
t.string :person_address_city
t.string :person_address_state
t.string :person_address_zip
t.string :person_address_country
t.string :person_phone
t.string :person_email
t.string :person_title
t.string :person_company
t.timestamps
end
end
end

View File

@@ -0,0 +1,25 @@
class CreateMusicReleases < ActiveRecord::Migration[5.2]
def change
create_table :music_releases do |t|
t.belongs_to :project, foreign_key: true
t.belongs_to :contract_template, foreign_key: true
t.string :locale
t.text :notes
t.integer :tagging_status, default: 0
t.string :name
t.string :person_name
t.string :person_address_street1
t.string :person_address_street2
t.string :person_address_city
t.string :person_address_state
t.string :person_address_zip
t.string :person_address_country
t.string :person_phone
t.string :person_email
t.string :person_title
t.string :person_company
t.timestamps
end
end
end

View File

@@ -0,0 +1,21 @@
MIGRATION_BASE_CLASS = if ActiveRecord::VERSION::MAJOR >= 5
ActiveRecord::Migration[5.0]
else
ActiveRecord::Migration
end
class RailsSettingsMigration < MIGRATION_BASE_CLASS
def self.up
create_table :settings do |t|
t.string :var, :null => false
t.text :value
t.references :target, :null => false, :polymorphic => true
t.timestamps :null => true
end
add_index :settings, [ :target_type, :target_id, :var ], :unique => true
end
def self.down
drop_table :settings
end
end

View File

@@ -0,0 +1,5 @@
class AddParentIdToContractTemplates < ActiveRecord::Migration[5.2]
def change
add_column :contract_templates, :parent_id, :integer
end
end

View File

@@ -0,0 +1,5 @@
class AddReportPublishedAtToVideos < ActiveRecord::Migration[5.2]
def change
add_column :videos, :report_published_at, :datetime
end
end

View File

@@ -0,0 +1,5 @@
class AddCollectionUidToAcquiredMediaReleases < ActiveRecord::Migration[5.2]
def change
add_column :acquired_media_releases, :collection_uid, :string
end
end

View File

@@ -0,0 +1,5 @@
class AddAdditionalInfoToVideoReleaseConfirmations < ActiveRecord::Migration[5.2]
def change
add_column :video_release_confirmations, :additional_info, :text
end
end

View File

@@ -0,0 +1,11 @@
class CreateGraphicsElementsTable < ActiveRecord::Migration[5.2]
def change
create_table :graphics_elements do |t|
t.references :video, foreign_key: true
t.text :text
t.string :time_elapsed
t.timestamps
end
end
end

View File

@@ -0,0 +1,5 @@
class AddAdditionalInfoToGraphicsElements < ActiveRecord::Migration[5.2]
def change
add_column :graphics_elements, :additional_info, :text
end
end

View File

@@ -0,0 +1,12 @@
class CreateFileInfos < ActiveRecord::Migration[5.2]
def change
create_table :file_infos do |t|
t.belongs_to :acquired_media_release, foreign_key: true
t.string :filename, null: false
t.string :content_type
t.integer :byte_size
t.timestamps
end
end
end

View File

@@ -0,0 +1,5 @@
class AddFileInfoToVideoReleaseConfirmations < ActiveRecord::Migration[5.2]
def change
add_reference :video_release_confirmations, :file_info, foreign_key: true
end
end

View File

@@ -0,0 +1,6 @@
class AddTerritoryAndTermToAcquiredMediaRelease < ActiveRecord::Migration[5.2]
def change
add_column :acquired_media_releases, :territory, :string
add_column :acquired_media_releases, :term, :string
end
end

View File

@@ -0,0 +1,5 @@
class ConvertFileInfosByteSizeToBigint < ActiveRecord::Migration[5.2]
def change
change_column :file_infos, :byte_size, :bigint
end
end

View File

@@ -0,0 +1,10 @@
class ConvertAdditionalInfoHashToColumnsForVideoReleaseConfirmations < ActiveRecord::Migration[5.2]
def change
add_column :video_release_confirmations, :timecode_in, :string
add_column :video_release_confirmations, :timecode_out, :string
add_column :video_release_confirmations, :duration, :string
add_column :video_release_confirmations, :source_file_name, :string
add_column :video_release_confirmations, :clip_name, :string
add_column :video_release_confirmations, :description, :string
end
end

View File

@@ -0,0 +1,10 @@
class ConvertAdditionalInfoHashToColumnsForGraphicsElements < ActiveRecord::Migration[5.2]
def change
add_column :graphics_elements, :timecode_in, :string
add_column :graphics_elements, :timecode_out, :string
add_column :graphics_elements, :duration, :string
add_column :graphics_elements, :source_file_name, :string
add_column :graphics_elements, :clip_name, :string
add_column :graphics_elements, :description, :string
end
end

View File

@@ -0,0 +1,10 @@
class AddEdlAttributesToUnreleasedAppearances < ActiveRecord::Migration[5.2]
def change
add_column :unreleased_appearances, :timecode_in, :string
add_column :unreleased_appearances, :timecode_out, :string
add_column :unreleased_appearances, :duration, :string
add_column :unreleased_appearances, :source_file_name, :string
add_column :unreleased_appearances, :clip_name, :string
add_column :unreleased_appearances, :description, :string
end
end

View File

@@ -0,0 +1,5 @@
class DropAreaReleases < ActiveRecord::Migration[5.2]
def change
drop_table :area_releases
end
end

View File

@@ -0,0 +1,12 @@
class RemoveSsnFieldsFromTalentAndAppearanceReleases < ActiveRecord::Migration[5.2]
def change
remove_column :talent_releases, :encrypted_person_ssn, :string
remove_column :talent_releases, :encrypted_person_ssn_iv, :string
remove_column :talent_releases, :encrypted_guardian_ssn, :string
remove_column :talent_releases, :encrypted_guardian_ssn_iv, :string
remove_column :appearance_releases, :encrypted_person_ssn, :string
remove_column :appearance_releases, :encrypted_person_ssn_iv, :string
remove_column :appearance_releases, :guardian_ssn, :string
end
end

View File

@@ -0,0 +1,5 @@
class AddEdlStartTimecodeToVideos < ActiveRecord::Migration[5.2]
def change
add_column :videos, :edl_start_timecode, :string
end
end

View File

@@ -0,0 +1,5 @@
class RenameEdlStartTimecodeToEdlTimecodeStart < ActiveRecord::Migration[5.2]
def change
rename_column :videos, :edl_start_timecode, :edl_timecode_start
end
end

View File

@@ -0,0 +1,5 @@
class AddEdlTypeToGraphicsElements < ActiveRecord::Migration[5.2]
def change
add_column :graphics_elements, :edl_type, :string
end
end

Some files were not shown because too many files have changed in this diff Show More