Flatten schema migrations

This commit is contained in:
Kevin McConnell
2025-11-11 12:28:34 +00:00
committed by Mike Dalessio
parent fa964240e9
commit 4e44cd5444
193 changed files with 521 additions and 1904 deletions
@@ -1,9 +0,0 @@
class CreateOrganizations < ActiveRecord::Migration[8.0]
def change
create_table :organizations do |t|
t.string :name, null: false, index: { unique: true }
t.timestamps
end
end
end
-14
View File
@@ -1,14 +0,0 @@
class CreateUsers < ActiveRecord::Migration[8.0]
def change
create_table :users do |t|
t.references :organization, null: false, foreign_key: true
t.string :name, null: false
t.string :email_address, null: false, index: { unique: true }
t.string :password_digest, null: false
t.boolean :active, null: false, default: true
t.timestamps
end
end
end
@@ -1,11 +0,0 @@
class CreateSplats < ActiveRecord::Migration[8.0]
def change
create_table :splats do |t|
t.string :title
t.text :body
t.string :color
t.timestamps
end
end
end
@@ -1,9 +0,0 @@
class CreateCategories < ActiveRecord::Migration[8.0]
def change
create_table :categories do |t|
t.string :title
t.timestamps
end
end
end
@@ -1,10 +0,0 @@
class CreateCategorizations < ActiveRecord::Migration[8.0]
def change
create_table :categorizations do |t|
t.references :splat, null: false, foreign_key: true
t.references :category, null: false, foreign_key: true
t.timestamps
end
end
end
@@ -1,6 +0,0 @@
class RenameOrganizationsToAccounts < ActiveRecord::Migration[8.0]
def change
rename_table :organizations, :accounts
rename_column :users, :organization_id, :account_id
end
end
@@ -1,5 +0,0 @@
class AddCreatorToSplats < ActiveRecord::Migration[8.0]
def change
add_column :splats, :creator_id, :integer, null: false
end
end
@@ -1,11 +0,0 @@
class CreateComments < ActiveRecord::Migration[8.0]
def change
create_table :comments do |t|
t.text :body
t.integer :creator_id, null: false
t.integer :splat_id, null: false
t.timestamps
end
end
end
@@ -1,11 +0,0 @@
class CreateBoosts < ActiveRecord::Migration[8.0]
def change
create_table :boosts do |t|
t.string :content
t.integer :creator_id, null: false
t.references :splat, null: false
t.timestamps
end
end
end
@@ -1,5 +0,0 @@
class AlignModels < ActiveRecord::Migration[8.0]
def change
rename_column :boosts, :content, :body
end
end
@@ -1,57 +0,0 @@
# This migration comes from active_storage (originally 20170806125915)
class CreateActiveStorageTables < ActiveRecord::Migration[7.0]
def change
# Use Active Record's configured type for primary and foreign keys
primary_key_type, foreign_key_type = primary_and_foreign_key_types
create_table :active_storage_blobs, id: primary_key_type do |t|
t.string :key, null: false
t.string :filename, null: false
t.string :content_type
t.text :metadata
t.string :service_name, null: false
t.bigint :byte_size, null: false
t.string :checksum
if connection.supports_datetime_with_precision?
t.datetime :created_at, precision: 6, null: false
else
t.datetime :created_at, null: false
end
t.index [ :key ], unique: true
end
create_table :active_storage_attachments, id: primary_key_type do |t|
t.string :name, null: false
t.references :record, null: false, polymorphic: true, index: false, type: foreign_key_type
t.references :blob, null: false, type: foreign_key_type
if connection.supports_datetime_with_precision?
t.datetime :created_at, precision: 6, null: false
else
t.datetime :created_at, null: false
end
t.index [ :record_type, :record_id, :name, :blob_id ], name: :index_active_storage_attachments_uniqueness, unique: true
t.foreign_key :active_storage_blobs, column: :blob_id
end
create_table :active_storage_variant_records, id: primary_key_type do |t|
t.belongs_to :blob, null: false, index: false, type: foreign_key_type
t.string :variation_digest, null: false
t.index [ :blob_id, :variation_digest ], name: :index_active_storage_variant_records_uniqueness, unique: true
t.foreign_key :active_storage_blobs, column: :blob_id
end
end
private
def primary_and_foreign_key_types
config = Rails.configuration.generators
setting = config.options[config.orm][:primary_key_type]
primary_key_type = setting || :primary_key
foreign_key_type = setting || :bigint
[ primary_key_type, foreign_key_type ]
end
end
@@ -1,9 +0,0 @@
class RenameSplatsToBubbles < ActiveRecord::Migration[8.0]
def change
rename_table :splats, :bubbles
rename_column :categorizations, :splat_id, :bubble_id
rename_column :boosts, :splat_id, :bubble_id
rename_column :comments, :splat_id, :bubble_id
end
end
@@ -1,8 +0,0 @@
class RenameCategoriesToTags < ActiveRecord::Migration[8.0]
def change
rename_table :categories, :tags
rename_table :categorizations, :taggings
rename_column :taggings, :category_id, :tag_id
end
end
@@ -1,5 +0,0 @@
class AddDueDateToBubbles < ActiveRecord::Migration[8.0]
def change
add_column :bubbles, :due_on, :date
end
end
@@ -1,11 +0,0 @@
class CreateProjects < ActiveRecord::Migration[8.0]
def change
create_table :projects do |t|
t.references :account, null: false
t.references :creator, null: false
t.string :name, null: false
t.timestamps
end
end
end
@@ -1,11 +0,0 @@
class CreateAccesses < ActiveRecord::Migration[8.0]
def change
create_table :accesses do |t|
t.references :project, null: false
t.references :user, null: false
t.timestamps
t.index [ :project_id, :user_id ], unique: true
end
end
end
@@ -1,11 +0,0 @@
class AddProjectToBubbles < ActiveRecord::Migration[8.0]
def change
change_table :bubbles do |t|
t.references :project, null: true
end
execute "update bubbles set project_id = (select id from projects limit 1)"
change_column_null :bubbles, :project_id, false
end
end
@@ -1,10 +0,0 @@
class CreateAssignments < ActiveRecord::Migration[8.0]
def change
create_table :assignments do |t|
t.references :user, null: false, foreign_key: true
t.references :bubble, null: false, foreign_key: true
t.timestamps
end
end
end
@@ -1,5 +0,0 @@
class RemoveBodyFromBubbles < ActiveRecord::Migration[8.0]
def change
remove_column :bubbles, :body, :string
end
end
@@ -1,5 +0,0 @@
class RemoveBodyFromBoosts < ActiveRecord::Migration[8.0]
def change
remove_column :boosts, :body, :string
end
end
@@ -1,7 +0,0 @@
class AddJoinCodeToAccounts < ActiveRecord::Migration[8.0]
def change
change_table :accounts do |t|
t.string :join_code, index: { unique: true }
end
end
end
@@ -1,8 +0,0 @@
class RenameProjectToBucket < ActiveRecord::Migration[8.0]
def change
rename_table :projects, :buckets
rename_column :accesses, :project_id, :bucket_id
rename_column :bubbles, :project_id, :bucket_id
end
end
@@ -1,6 +0,0 @@
class RemoveFkConstraintsFromAssignments < ActiveRecord::Migration[8.0]
def change
remove_foreign_key :assignments, :bubbles
remove_foreign_key :assignments, :users
end
end
@@ -1,11 +0,0 @@
class AddAccountToTags < ActiveRecord::Migration[8.0]
def change
change_table :tags do |t|
t.references :account, null: true
end
execute "update tags set account_id = (select id from accounts limit 1)"
change_column_null :tags, :account_id, false
end
end
@@ -1,7 +0,0 @@
class CreateSearchIndexes < ActiveRecord::Migration[8.0]
def change
# # TODO:PLANB: need to replace SQLite FTS
# create_virtual_table :bubbles_search_index, "fts5", [ "title" ]
# create_virtual_table :comments_search_index, "fts5", [ "body" ]
end
end
-10
View File
@@ -1,10 +0,0 @@
class CreatePops < ActiveRecord::Migration[8.0]
def change
create_table :pops do |t|
t.references :bubble, null: false, foreign_key: true, index: { unique: true }
t.references :user, null: true, foreign_key: true
t.timestamps
end
end
end
@@ -1,5 +0,0 @@
class RenameAssignmentUserToAssignee < ActiveRecord::Migration[8.0]
def change
rename_column :assignments, :user_id, :assignee_id
end
end
@@ -1,7 +0,0 @@
class AddAssignerToAssignments < ActiveRecord::Migration[8.0]
def change
add_column :assignments, :assigner_id, :integer
execute "update assignments set assigner_id = assignee_id"
change_column_null :assignments, :assigner_id, false
end
end
@@ -1,5 +0,0 @@
class AddUniqueIndexToAssignments < ActiveRecord::Migration[8.0]
def change
add_index :assignments, %i[ assignee_id bubble_id ], unique: true
end
end
@@ -1,5 +0,0 @@
class MakeCommentBodiesNotNull < ActiveRecord::Migration[8.0]
def change
change_column_null :comments, :body, false
end
end
@@ -1,14 +0,0 @@
class CreateEvents < ActiveRecord::Migration[8.0]
def change
create_table :events do |t|
t.references :bubble, null: false, index: false
t.references :creator, null: false
t.column :particulars, :json, default: -> { '(JSON_OBJECT())' }
t.string :action, null: false
t.timestamps
end
add_index :events, %i[ bubble_id action ], name: "index_events_on_bubble_id_and_action"
end
end
-5
View File
@@ -1,5 +0,0 @@
class DropBoosts < ActiveRecord::Migration[8.0]
def change
drop_table :boosts
end
end
@@ -1,5 +0,0 @@
class AddBoostCountToBubbles < ActiveRecord::Migration[8.0]
def change
add_column :bubbles, :boost_count, :integer, null: false, default: 0
end
end
@@ -1,5 +0,0 @@
class RemoveAssignmentsIndexOnAssigneeId < ActiveRecord::Migration[8.0]
def change
remove_index :assignments, :assignee_id
end
end
-11
View File
@@ -1,11 +0,0 @@
class CreateViews < ActiveRecord::Migration[8.0]
def change
create_table :bucket_views do |t|
t.references :creator, null: false
t.references :bucket, null: false
t.column :filters, :json, default: -> { '(JSON_OBJECT())' }, null: false
t.timestamps
end
end
end
@@ -1,11 +0,0 @@
class MakeBucketViewFiltersUnique < ActiveRecord::Migration[8.0]
def change
# MySQL doesn't support direct indexing of JSON columns. To ensure uniqueness
# of the filters JSON content, we create a generated column that stores a SHA2
# hash of the JSON data. This allows us to enforce that each creator can only
# have one view per bucket with the same filter configuration.
add_column :bucket_views, :filters_hash, :string, limit: 64, as: "SHA2(filters, 256)", stored: true
add_index :bucket_views, %i[ bucket_id creator_id filters_hash ], unique: true
remove_index :bucket_views, :bucket_id
end
end
@@ -1,10 +0,0 @@
class CreateWorkflows < ActiveRecord::Migration[8.0]
def change
create_table :workflows do |t|
t.references :account, null: false, foreign_key: true
t.string :name, null: false
t.timestamps
end
end
end
@@ -1,10 +0,0 @@
class CreateWorkflowStages < ActiveRecord::Migration[8.0]
def change
create_table :workflow_stages do |t|
t.references :workflow, null: false, foreign_key: true
t.string :name, null: false
t.timestamps
end
end
end
@@ -1,5 +0,0 @@
class AddWorkflowStageToBubbles < ActiveRecord::Migration[8.0]
def change
add_reference :bubbles, :stage, null: true, foreign_key: { to_table: :workflow_stages }
end
end
@@ -1,10 +0,0 @@
class CreateMessages < ActiveRecord::Migration[8.0]
def change
create_table :messages do |t|
t.references :bubble, null: false, foreign_key: true
t.references :messageable, polymorphic: true, null: false, index: { unique: true }
t.timestamps
end
end
end
@@ -1,7 +0,0 @@
class CreateEventSummaries < ActiveRecord::Migration[8.0]
def change
create_table :event_summaries do |t|
t.timestamps
end
end
end
@@ -1,9 +0,0 @@
class AddSummaryReferenceToEvents < ActiveRecord::Migration[8.0]
def change
add_reference :events, :summary, foreign_key: { to_table: :event_summaries }, index: false
add_index :events, %i[ summary_id action ]
remove_index :events, %i[ bubble_id action ]
remove_column :events, :bubble_id, :references, null: false, index: false
end
end
@@ -1,5 +0,0 @@
class RemoveBubbleReferenceFromComments < ActiveRecord::Migration[8.0]
def change
remove_column :comments, :bubble_id, :references, null: false, index: false
end
end
@@ -1,5 +0,0 @@
class MakeEventSummaryNotNull < ActiveRecord::Migration[8.0]
def change
change_column_null :events, :summary_id, false
end
end
@@ -1,20 +0,0 @@
class RenameBucketViewsToFilters < ActiveRecord::Migration[8.0]
def change
rename_table :bucket_views, :filters
remove_index :filters, %i[ bucket_id creator_id filters_hash ], unique: true
remove_index :filters, :creator_id
remove_column :filters, :filters_hash, :string
remove_reference :filters, :bucket
rename_column :filters, :filters, :params
add_column :filters, :fields, :json, null: false, default: -> { '(JSON_OBJECT())' }
# MySQL doesn't support direct indexing of JSON columns. Create a generated
# hash column for the params JSON data to enforce uniqueness.
add_column :filters, :params_hash, :string, limit: 64, as: "SHA2(params, 256)", stored: true
add_index :filters, %i[ creator_id params_hash ], unique: true
end
end
@@ -1,18 +0,0 @@
class CreateFilterJoinTables < ActiveRecord::Migration[8.0]
def change
create_join_table :filters, :tags do |t|
t.index :filter_id
t.index :tag_id
end
create_join_table :filters, :buckets do |t|
t.index :filter_id
t.index :bucket_id
end
create_join_table :filters, :assignees do |t|
t.index :filter_id
t.index :assignee_id
end
end
end
@@ -1,10 +0,0 @@
class HashFilterParams < ActiveRecord::Migration[8.0]
def change
remove_index :filters, %i[ creator_id params_hash ], unique: true
remove_column :filters, :params_hash
remove_column :filters, :params
add_column :filters, :params_digest, :string, null: false
add_index :filters, %i[ creator_id params_digest ], unique: true
end
end
@@ -1,8 +0,0 @@
class CreateFilterAssignerJoinTable < ActiveRecord::Migration[8.0]
def change
create_join_table :filters, :assigners do |t|
t.index :filter_id
t.index :assigner_id
end
end
end
@@ -1,5 +0,0 @@
class AddCommentsCountToBubbles < ActiveRecord::Migration[8.0]
def change
add_column :bubbles, :comments_count, :integer, null: false, default: 0
end
end
@@ -1,5 +0,0 @@
class AddActivityScoreToBubbles < ActiveRecord::Migration[8.0]
def change
add_column :bubbles, :activity_score, :integer, null: false, default: 0
end
end
@@ -1,5 +0,0 @@
class RenameBoostCountToBoostsCount < ActiveRecord::Migration[8.0]
def change
rename_column :bubbles, :boost_count, :boosts_count
end
end
@@ -1,9 +0,0 @@
class MakeTaggingsUniquePerBubble < ActiveRecord::Migration[8.0]
def change
# Add the composite index first, then remove the old single-column index.
# MySQL requires an index for foreign key constraints, so we need the new
# composite index in place before removing the old one.
add_index :taggings, %i[ bubble_id tag_id ], unique: true
remove_index :taggings, :bubble_id
end
end
@@ -1,5 +0,0 @@
class RemoveBodyFromComments < ActiveRecord::Migration[8.0]
def change
remove_column :comments, :body, :text, null: false
end
end
@@ -1,5 +0,0 @@
class AddAllAccessToBucket < ActiveRecord::Migration[8.1]
def change
add_column :buckets, :all_access, :boolean, default: false, null: false
end
end
@@ -1,5 +0,0 @@
class AddStatusToBubbles < ActiveRecord::Migration[8.1]
def change
add_column :bubbles, :status, :string, default: "drafted", null: false
end
end
@@ -1,15 +0,0 @@
class CreateNotifications < ActiveRecord::Migration[8.1]
def change
create_table :notifications do |t|
t.references :user, null: false, foreign_key: true
t.references :event, null: false, foreign_key: true
t.references :bubble, null: false, foreign_key: true
t.references :resource, null: false, polymorphic: true, index: true
t.boolean :read, default: false, null: false
t.timestamps
t.index %i[ user_id read created_at ], order: { read: :desc, created_at: :desc }
end
end
end
@@ -1,5 +0,0 @@
class EnsureExistingBubblesArePublished < ActiveRecord::Migration[8.1]
def change
execute "update bubbles set status = 'published' where status = 'drafted'"
end
end
@@ -1,12 +0,0 @@
class ChangeNotificationReadToReadAt < ActiveRecord::Migration[8.1]
def change
remove_index :notifications, %i[ user_id read created_at ], order: { read: :desc, created_at: :desc }
change_table :notifications do |t|
t.remove :read
t.datetime :read_at
t.index %i[ user_id read_at created_at ], order: { read_at: :desc, created_at: :desc }
end
end
end
@@ -1,17 +0,0 @@
class AssociateEventsWithBubbles < ActiveRecord::Migration[8.1]
def change
change_table :events do |t|
t.references :bubble, foreign_key: true
end
# MySQL uses JOIN syntax for multi-table updates, not FROM clause
execute "
update events
join event_summaries es on events.summary_id = es.id
join messages m on m.messageable_type = 'EventSummary' and m.messageable_id = es.id
set events.bubble_id = m.bubble_id
"
change_column_null :events, :bubble_id, false
end
end
@@ -1,8 +0,0 @@
class CreateFilterStagesJoinTable < ActiveRecord::Migration[8.1]
def change
create_join_table :filters, :stages do |t|
t.index :filter_id
t.index :stage_id
end
end
end
@@ -1,5 +0,0 @@
class AddDueDateToEvents < ActiveRecord::Migration[8.1]
def change
add_column :events, :due_date, :date
end
end
@@ -1,5 +0,0 @@
class ChangeBubblesStatusDefaultToCreating < ActiveRecord::Migration[8.1]
def change
change_column_default :bubbles, :status, :creating
end
end
@@ -1,10 +0,0 @@
class AddRoleToUsers < ActiveRecord::Migration[8.1]
def change
change_table :users do |t|
t.string :role, null: false, default: :member, index: true
end
change_column_null :users, :email_address, true
change_column_null :users, :password_digest, true
end
end
@@ -1,21 +0,0 @@
class AddAutoPopAtToBubbles < ActiveRecord::Migration[8.1]
def change
change_table :bubbles do |t|
t.datetime :auto_pop_at, index: true
end
# MySQL uses JOIN syntax for multi-table updates and DATE_ADD for date arithmetic
execute "
update bubbles
join (
select bubbles.id as bubble_id, coalesce(max(events.created_at), bubbles.created_at) as last_active_at
from bubbles
left join events on bubbles.id = events.bubble_id
group by bubbles.id
) as activity on bubbles.id = activity.bubble_id
set bubbles.auto_pop_at = DATE_ADD(activity.last_active_at, INTERVAL 30 DAY)
"
change_column_null :bubbles, :auto_pop_at, false
end
end
@@ -1,14 +0,0 @@
class CreateReactions < ActiveRecord::Migration[8.1]
def change
create_table :reactions do |t|
t.integer :comment_id, null: false
t.integer :reacter_id, null: false
t.string :content, limit: 16, null: false
t.timestamps
end
add_index :reactions, :comment_id
add_index :reactions, :reacter_id
end
end
@@ -1,11 +0,0 @@
class CreateCreatorsFiltersJoinTable < ActiveRecord::Migration[8.1]
def change
create_table :creators_filters, id: false do |t|
t.integer :filter_id, null: false
t.integer :creator_id, null: false
end
add_index :creators_filters, :filter_id
add_index :creators_filters, :creator_id
end
end
@@ -1,7 +0,0 @@
class DropAssignersFiltersJoinTable < ActiveRecord::Migration[8.1]
class DropAssignersFiltersJoinTable < ActiveRecord::Migration[7.1]
def change
drop_table :assigners_filters if table_exists?(:assigners_filters)
end
end
end
@@ -1,11 +0,0 @@
class CreateWatches < ActiveRecord::Migration[8.1]
def change
create_table :watches do |t|
t.references :user, null: false, foreign_key: true
t.references :bubble, null: false, foreign_key: true
t.boolean :watching, null: false, default: true
t.timestamps
end
end
end
@@ -1,18 +0,0 @@
class CreateSubscriptions < ActiveRecord::Migration[8.1]
def change
create_table :subscriptions do |t|
t.references :subscribable, polymorphic: true, null: false, index: true
t.references :user, null: false, foreign_key: true
t.timestamps
t.index [ :subscribable_type, :subscribable_id, :user_id ], unique: true
end
# Subscribe everyone to their current buckets to start with
execute "
insert into subscriptions (subscribable_type, subscribable_id, user_id, created_at, updated_at)
select 'Bucket', bucket_id, user_id, current_timestamp, current_timestamp from accesses;
"
end
end
@@ -1,11 +0,0 @@
class AddActivityScoreAtToBubbles < ActiveRecord::Migration[8.1]
def change
change_table :bubbles do |t|
t.datetime :activity_score_at
t.float :activity_score_order, null: false, default: 0
t.change :activity_score, :float, null: false, default: 0
t.index :activity_score_order, order: :desc
end
end
end
-11
View File
@@ -1,11 +0,0 @@
class CreatePins < ActiveRecord::Migration[7.0]
def change
create_table :pins do |t|
t.references :bubble, null: false, foreign_key: true
t.references :user, null: false, foreign_key: true
t.timestamps
end
add_index :pins, [ :bubble_id, :user_id ], unique: true
end
end
@@ -1,7 +0,0 @@
class AddInvolvementToAccesses < ActiveRecord::Migration[8.1]
def change
change_table :accesses do |t|
t.string :involvement, null: false, default: "watching"
end
end
end
@@ -1,16 +0,0 @@
class DropSubscriptions < ActiveRecord::Migration[8.1]
def change
execute "
update accesses set involvement = 'access_only'
"
# MySQL uses JOIN syntax for multi-table updates
execute "
update accesses
join (select user_id, subscribable_id as bucket_id from subscriptions) as subscriptions
on subscriptions.user_id = accesses.user_id and subscriptions.bucket_id = accesses.bucket_id
set accesses.involvement = 'watching'
"
drop_table :subscriptions
end
end
@@ -1,5 +0,0 @@
class AddWorkflowToBuckets < ActiveRecord::Migration[8.1]
def change
add_reference :buckets, :workflow, null: true, foreign_key: true
end
end
@@ -1,9 +0,0 @@
class CreateBubbleEngagements < ActiveRecord::Migration[8.1]
def change
create_table :bubble_engagements do |t|
t.references :bubble, index: true
t.timestamps
end
end
end
@@ -1,20 +0,0 @@
class AddLastActiveAtToBubbles < ActiveRecord::Migration[8.1]
def change
add_column :bubbles, :last_active_at, :datetime
add_index :bubbles, %i[ last_active_at status ]
# MySQL uses JOIN syntax for multi-table updates
execute <<~SQL
update bubbles
join (
select bubbles.id as bubble_id, coalesce(max(events.created_at), bubbles.created_at) as last_active_at
from bubbles
left join events on bubbles.id = events.bubble_id
group by bubbles.id
) as activity on bubbles.id = activity.bubble_id
set bubbles.last_active_at = activity.last_active_at
SQL
change_column_null :bubbles, :last_active_at, false
end
end
@@ -1,5 +0,0 @@
class RemoveBubblesAutoPopAt < ActiveRecord::Migration[8.1]
def change
remove_column :bubbles, :auto_pop_at
end
end
@@ -1,18 +0,0 @@
class AddReasonToPops < ActiveRecord::Migration[8.1]
def change
add_column :pops, :reason, :string
create_table :pop_reasons do |t|
t.references :account, index: true
t.string :label
t.timestamps
end
execute <<~SQL
update pops set reason = 'Closed'
SQL
change_column_null :pops, :reason, false
end
end
@@ -1,5 +0,0 @@
class AddIndexToSortPopsByRecency < ActiveRecord::Migration[8.1]
def change
add_index :pops, %i[ bubble_id created_at ]
end
end
@@ -1,55 +0,0 @@
class RenameBubblesToCards < ActiveRecord::Migration[8.1]
def change
# Tables
rename_table "bubbles", "cards"
rename_table "bubble_engagements", "card_engagements"
rename_table "pops", "closures"
rename_table "pop_reasons", "closure_reasons"
rename_table "buckets", "collections"
rename_table "buckets_filters", "collections_filters"
# Columns
rename_column "assignments", "bubble_id", "card_id"
rename_column "card_engagements", "bubble_id", "card_id"
rename_column "events", "bubble_id", "card_id"
rename_column "messages", "bubble_id", "card_id"
rename_column "notifications", "bubble_id", "card_id"
rename_column "pins", "bubble_id", "card_id"
rename_column "closures", "bubble_id", "card_id"
rename_column "taggings", "bubble_id", "card_id"
rename_column "watches", "bubble_id", "card_id"
rename_column "cards", "bucket_id", "collection_id"
rename_column "accesses", "bucket_id", "collection_id"
rename_column "collections_filters", "bucket_id", "collection_id"
# Indexes
# # No longer necessary in MySQL
# rename_index "assignments", "index_assignments_on_bubble_id", "index_assignments_on_card_id"
# rename_index "card_engagements", "index_bubble_engagements_on_bubble_id", "index_card_engagements_on_card_id"
# rename_index "events", "index_events_on_bubble_id", "index_events_on_card_id"
# rename_index "messages", "index_messages_on_bubble_id", "index_messages_on_card_id"
# rename_index "notifications", "index_notifications_on_bubble_id", "index_notifications_on_card_id"
# rename_index "pins", "index_pins_on_bubble_id", "index_pins_on_card_id"
# rename_index "pins", "index_pins_on_bubble_id_and_user_id", "index_pins_on_card_id_and_user_id"
# rename_index "closures", "index_pops_on_bubble_id", "index_closures_on_card_id"
# rename_index "closures", "index_pops_on_bubble_id_and_created_at", "index_closures_on_card_id_and_created_at"
# rename_index "watches", "index_watches_on_bubble_id", "index_watches_on_card_id"
# rename_index "taggings", "index_taggings_on_bubble_id_and_tag_id", "index_taggings_on_card_id_and_tag_id"
# rename_index "accesses", "index_accesses_on_bucket_id", "index_accesses_on_collection_id"
# rename_index "accesses", "index_accesses_on_bucket_id_and_user_id", "index_accesses_on_collection_id_and_user_id"
# rename_index "collections_filters", "index_buckets_filters_on_bucket_id", "index_collections_filters_on_collection_id"
# Search tables
# # TODO:PLANB: need to replace SQLite FTS
# execute <<~SQL
# CREATE VIRTUAL TABLE cards_search_index USING fts5(title);
# INSERT INTO cards_search_index(title) SELECT title FROM bubbles_search_index;
# SQL
# execute <<~SQL
# DROP TABLE bubbles_search_index;
# SQL
end
end
@@ -1,5 +0,0 @@
class AddColorToWorkflowStages < ActiveRecord::Migration[8.1]
def change
add_column :workflow_stages, :color, :string
end
end
@@ -1,5 +0,0 @@
class RemoveColorFromCards < ActiveRecord::Migration[8.1]
def change
remove_column :cards, :color, :string
end
end
@@ -1,6 +0,0 @@
class AddAccessedAtToAccesses < ActiveRecord::Migration[8.1]
def change
add_column :accesses, :accessed_at, :datetime
add_index :accesses, :accessed_at, order: { accessed_at: :desc }
end
end
@@ -1,9 +0,0 @@
class CreateCardGoldnesses < ActiveRecord::Migration[8.1]
def change
create_table :card_goldnesses do |t|
t.references :card, null: false, foreign_key: true, index: { unique: true }
t.timestamps
end
end
end
@@ -1,5 +0,0 @@
class DropCardCommentsCount < ActiveRecord::Migration[8.1]
def change
remove_column :cards, :comments_count
end
end
@@ -1,5 +0,0 @@
class RemoveBoostsCountFromCards < ActiveRecord::Migration[8.1]
def change
remove_column :cards, :boosts_count
end
end
@@ -1,9 +0,0 @@
class RemoveAccountIds < ActiveRecord::Migration[8.1]
def change
remove_column :closure_reasons, :account_id
remove_column :collections, :account_id
remove_column :tags, :account_id
remove_column :users, :account_id
remove_column :workflows, :account_id
end
end
@@ -1,5 +0,0 @@
class RemoveAccountsNameIndex < ActiveRecord::Migration[8.1]
def change
remove_index :accounts, :name
end
end
@@ -1,5 +0,0 @@
class RemoveAccountsJoinCodeIndex < ActiveRecord::Migration[8.1]
def change
remove_index :accounts, :join_code
end
end
@@ -1,8 +0,0 @@
class RemoveActivityFromCards < ActiveRecord::Migration[8.1]
def change
remove_index :cards, :activity_score_order
remove_column :cards, :activity_score_order
remove_column :cards, :activity_score_at
remove_column :cards, :activity_score
end
end
@@ -1,11 +0,0 @@
class CreateMentions < ActiveRecord::Migration[8.1]
def change
create_table :mentions do |t|
t.references :source, polymorphic: true, null: false, index: true
t.references :mentionee, foreign_key: { to_table: :users }, null: false
t.references :mentioner, foreign_key: { to_table: :users }, null: false
t.timestamps
end
end
end
@@ -1,11 +0,0 @@
class AddSourceToNotifications < ActiveRecord::Migration[8.1]
def change
add_reference :notifications, :source, polymorphic: true, index: true
execute <<~SQL
update notifications set source_type = 'Event', source_id = event_id;
SQL
change_column_null :notifications, :source_type, false
end
end
@@ -1,6 +0,0 @@
class RemoveUnusedColumnsFromNotifications < ActiveRecord::Migration[8.1]
def change
remove_column :notifications, :event_id
remove_column :notifications, :card_id
end
end
@@ -1,5 +0,0 @@
class RemoveDueDateFromEvents < ActiveRecord::Migration[8.1]
def change
remove_column :events, :due_date
end
end
@@ -1,18 +0,0 @@
class AddCreatorToNotifications < ActiveRecord::Migration[8.1]
def change
add_reference :notifications, :creator, null: true, foreign_key: { to_table: :users }
execute <<~SQL
UPDATE notifications
SET creator_id = (
SELECT events.creator_id
FROM events
WHERE events.id = notifications.source_id
AND notifications.source_type = 'Event'
)
WHERE source_type = 'Event';
SQL
change_column_null :notifications, :creator_id, true
end
end
@@ -1,5 +0,0 @@
class RemoveNotificationResources < ActiveRecord::Migration[8.1]
def change
remove_reference :notifications, :resource, polymorphic: true, index: true
end
end
@@ -1,14 +0,0 @@
class MakeEventsEventable < ActiveRecord::Migration[8.1]
def change
add_reference :events, :eventable, polymorphic: true, index: true
execute <<~SQL
update events set eventable_type = 'Card', eventable_id = card_id;
SQL
change_column_null :events, :eventable_id, false
change_column_null :events, :eventable_type, false
remove_reference :events, :card
end
end
@@ -1,5 +0,0 @@
class MakeNotificationsSourceIdNotNullable < ActiveRecord::Migration[8.1]
def change
change_column_null :notifications, :source_id, false
end
end
@@ -1,17 +0,0 @@
class AddCollectionIdToEvents < ActiveRecord::Migration[8.1]
def change
add_reference :events, :collection, foreign_key: true, index: true
execute <<~SQL
UPDATE events
SET collection_id = (
SELECT cards.collection_id
FROM cards
WHERE cards.id = events.eventable_id
)
WHERE eventable_type = 'Card'#{' '}
SQL
change_column_null :events, :collection_id, false
end
end
@@ -1,5 +0,0 @@
class MakeEventSummaryOptional < ActiveRecord::Migration[8.1]
def change
change_column_null :events, :summary_id, true
end
end

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