Skip to content

Commit

Permalink
Migrate data from the old table to the new one
Browse files Browse the repository at this point in the history
  • Loading branch information
hellcp-work committed Jan 30, 2023
1 parent beef4a3 commit ad8eadb
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 54 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ gem 'sqlite3', '~> 1.6.0'

# This can only be removed with Rails 7.0
gem 'psych', '< 4.0'
gem 'mail', '< 2.8.0'

# Use SCSS for stylesheets
gem 'sass-rails'
Expand Down
17 changes: 2 additions & 15 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ GEM
activerecord (>= 5.a)
database_cleaner-core (~> 2.0.0)
database_cleaner-core (2.0.1)
date (3.3.1)
date_validator (0.12.0)
activemodel (>= 3)
activesupport (>= 3)
Expand Down Expand Up @@ -196,11 +195,8 @@ GEM
loofah (2.19.1)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
mail (2.8.0)
mail (2.7.1)
mini_mime (>= 0.1.1)
net-imap
net-pop
net-smtp
marcel (1.0.2)
matrix (0.4.2)
method_source (1.0.0)
Expand All @@ -210,15 +206,6 @@ GEM
mini_racer (0.6.3)
libv8-node (~> 16.10.0.0)
minitest (5.17.0)
net-imap (0.3.2)
date
net-protocol
net-pop (0.1.2)
net-protocol
net-protocol (0.2.1)
timeout
net-smtp (0.3.3)
net-protocol
nio4r (2.5.8)
nokogiri (1.13.10)
mini_portile2 (~> 2.8.0)
Expand Down Expand Up @@ -385,7 +372,6 @@ GEM
thor (1.2.1)
thread_safe (0.3.6)
tilt (2.0.11)
timeout (0.3.1)
ttfunk (1.0.3)
tzinfo (1.2.10)
thread_safe (~> 0.1)
Expand Down Expand Up @@ -439,6 +425,7 @@ DEPENDENCIES
kaminari
letter_opener_web
listen
mail (< 2.8.0)
mini_racer
pdf-reader
prawn (~> 0.13.0)
Expand Down
4 changes: 2 additions & 2 deletions db/migrate/20221210104059_update_columns_in_audits.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ def change
add_column :audits, :remote_address, :string
add_column :audits, :username, :string
add_column :audits, :request_uuid, :string
add_column :audits, :association_id, :integer
add_column :audits, :association_type, :string
add_column :audits, :associated_id, :integer
add_column :audits, :associated_type, :string

change_column_null :audits, :auditable_id, true
change_column_null :audits, :auditable_type, true
Expand Down
12 changes: 12 additions & 0 deletions db/migrate/20230130095633_merge_audit_tables.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# frozen_string_literal: true

class MergeAuditTables < ActiveRecord::Migration[5.1]
def self.up
execute "INSERT INTO audits(auditable_id, auditable_type, user_id, user_type, action, audited_changes, version, comment, remote_address, created_at) SELECT auditable_id, auditable_type, user_id, user_type, action, audited_changes, version, comment, remote_address, created_at FROM espinita_audits;"
drop_table :espinita_audits
end

def self.down
raise IrreversibleMigration
end
end
77 changes: 40 additions & 37 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,13 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20221210104059) do
ActiveRecord::Schema.define(version: 20230130095633) do

create_table "audits", force: :cascade do |t|
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
enable_extension "pg_stat_statements"

create_table "audits", id: :serial, force: :cascade do |t|
t.integer "auditable_id"
t.string "auditable_type"
t.integer "user_id"
Expand All @@ -25,15 +29,19 @@
t.string "remote_address"
t.string "username"
t.string "request_uuid"
t.integer "association_id"
t.string "association_type"
t.integer "associated_id"
t.string "associated_type"
t.index ["associated_type", "associated_id"], name: "associated_index"
t.index ["auditable_id", "auditable_type", "version"], name: "idx_27755812_auditable_index"
t.index ["auditable_type", "auditable_id", "version"], name: "auditable_index"
t.index ["created_at"], name: "idx_27755812_index_audits_on_created_at"
t.index ["created_at"], name: "index_audits_on_created_at"
t.index ["request_uuid"], name: "index_audits_on_request_uuid"
t.index ["user_id", "user_type"], name: "idx_27755812_user_index"
t.index ["user_id", "user_type"], name: "user_index"
end

create_table "bank_accounts", force: :cascade do |t|
create_table "bank_accounts", id: :serial, force: :cascade do |t|
t.string "holder"
t.string "bank_name"
t.string "format"
Expand All @@ -48,28 +56,30 @@
t.datetime "updated_at"
end

create_table "budgets", force: :cascade do |t|
create_table "budgets", id: :serial, force: :cascade do |t|
t.string "name"
t.string "description"
t.decimal "amount", precision: 10, scale: 2
t.string "currency"
t.datetime "created_at"
t.datetime "updated_at"
t.index ["currency"], name: "idx_27755858_index_budgets_on_currency"
t.index ["currency"], name: "index_budgets_on_currency"
end

create_table "comments", force: :cascade do |t|
create_table "comments", id: :serial, force: :cascade do |t|
t.integer "machine_id"
t.string "machine_type"
t.text "body"
t.integer "user_id"
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "private"
t.index ["private"], name: "idx_27755803_index_comments_on_private"
t.index ["private"], name: "index_comments_on_private"
end

create_table "delayed_jobs", force: :cascade do |t|
create_table "delayed_jobs", id: :serial, force: :cascade do |t|
t.integer "priority", default: 0
t.integer "attempts", default: 0
t.text "handler"
Expand All @@ -82,25 +92,10 @@
t.datetime "created_at"
t.datetime "updated_at"
t.index ["priority", "run_at"], name: "delayed_jobs_priority"
t.index ["priority", "run_at"], name: "idx_27755792_delayed_jobs_priority"
end

create_table "espinita_audits", force: :cascade do |t|
t.string "auditable_type"
t.integer "auditable_id"
t.string "user_type"
t.integer "user_id"
t.text "audited_changes"
t.string "comment"
t.integer "version"
t.string "action"
t.string "remote_address"
t.datetime "created_at"
t.datetime "updated_at"
t.index ["auditable_type", "auditable_id"], name: "index_espinita_audits_on_auditable_type_and_auditable_id"
t.index ["user_type", "user_id"], name: "index_espinita_audits_on_user_type_and_user_id"
end

create_table "event_emails", force: :cascade do |t|
create_table "event_emails", id: :serial, force: :cascade do |t|
t.text "to"
t.string "subject"
t.text "body"
Expand All @@ -110,12 +105,12 @@
t.datetime "updated_at"
end

create_table "event_organizers", force: :cascade do |t|
create_table "event_organizers", id: :serial, force: :cascade do |t|
t.integer "event_id"
t.integer "user_id"
end

create_table "events", force: :cascade do |t|
create_table "events", id: :serial, force: :cascade do |t|
t.string "name", null: false
t.text "description"
t.string "country_code"
Expand All @@ -130,10 +125,11 @@
t.datetime "reimbursement_creation_deadline"
t.integer "budget_id"
t.string "shipment_type"
t.index ["budget_id"], name: "idx_27755747_index_events_on_budget_id"
t.index ["budget_id"], name: "index_events_on_budget_id"
end

create_table "payments", force: :cascade do |t|
create_table "payments", id: :serial, force: :cascade do |t|
t.integer "reimbursement_id"
t.date "date"
t.decimal "amount", precision: 10, scale: 2
Expand All @@ -149,7 +145,7 @@
t.datetime "updated_at"
end

create_table "postal_addresses", force: :cascade do |t|
create_table "postal_addresses", id: :serial, force: :cascade do |t|
t.string "line1"
t.string "line2"
t.string "city"
Expand All @@ -161,23 +157,23 @@
t.string "name"
end

create_table "reimbursement_attachments", force: :cascade do |t|
create_table "reimbursement_attachments", id: :serial, force: :cascade do |t|
t.integer "reimbursement_id"
t.string "title", null: false
t.string "file", null: false
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "reimbursement_links", force: :cascade do |t|
create_table "reimbursement_links", id: :serial, force: :cascade do |t|
t.integer "reimbursement_id"
t.string "title", null: false
t.string "url", null: false
t.datetime "created_at"
t.datetime "updated_at"
end

create_table "reimbursements", force: :cascade do |t|
create_table "reimbursements", id: :serial, force: :cascade do |t|
t.string "state"
t.integer "user_id", null: false
t.integer "request_id", null: false
Expand All @@ -188,7 +184,7 @@
t.string "acceptance_file"
end

create_table "request_expenses", force: :cascade do |t|
create_table "request_expenses", id: :serial, force: :cascade do |t|
t.integer "request_id", null: false
t.string "subject"
t.string "description"
Expand All @@ -202,7 +198,7 @@
t.decimal "authorized_amount", precision: 10, scale: 2
end

create_table "requests", force: :cascade do |t|
create_table "requests", id: :serial, force: :cascade do |t|
t.string "state"
t.integer "user_id", null: false
t.integer "event_id", null: false
Expand All @@ -214,13 +210,17 @@
t.integer "postal_address_id"
t.string "contact_phone_number"
t.string "type"
t.index ["event_id"], name: "idx_27755783_index_requests_on_event_id"
t.index ["event_id"], name: "index_requests_on_event_id"
t.index ["postal_address_id"], name: "idx_27755783_index_requests_on_postal_address_id"
t.index ["postal_address_id"], name: "index_requests_on_postal_address_id"
t.index ["type"], name: "idx_27755783_index_requests_on_type"
t.index ["type"], name: "index_requests_on_type"
t.index ["user_id"], name: "idx_27755783_index_requests_on_user_id"
t.index ["user_id"], name: "index_requests_on_user_id"
end

create_table "state_changes", force: :cascade do |t|
create_table "state_changes", id: :serial, force: :cascade do |t|
t.integer "machine_id", null: false
t.string "machine_type", null: false
t.string "state_event"
Expand All @@ -231,10 +231,11 @@
t.datetime "created_at"
t.datetime "updated_at"
t.string "type"
t.index ["type"], name: "idx_27755849_index_state_changes_on_type"
t.index ["type"], name: "index_state_changes_on_type"
end

create_table "user_profiles", force: :cascade do |t|
create_table "user_profiles", id: :serial, force: :cascade do |t|
t.integer "user_id", null: false
t.integer "role_id", null: false
t.string "full_name"
Expand All @@ -254,7 +255,7 @@
t.string "postal_address"
end

create_table "users", force: :cascade do |t|
create_table "users", id: :serial, force: :cascade do |t|
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
Expand All @@ -269,7 +270,9 @@
t.string "locale", default: "en", null: false
t.datetime "created_at"
t.datetime "updated_at"
t.index ["email"], name: "idx_27755725_index_users_on_email", unique: true
t.index ["email"], name: "index_users_on_email", unique: true
t.index ["reset_password_token"], name: "idx_27755725_index_users_on_reset_password_token", unique: true
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
end

Expand Down

0 comments on commit ad8eadb

Please sign in to comment.