Remove v1 migrations
This commit is contained in:
parent
c24f2d807f
commit
29549a5b57
52 changed files with 0 additions and 1003 deletions
|
@ -1,58 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class AddIndexesForPaymentAndSupporterQueries < ActiveRecord::Migration[4.2]
|
|
||||||
def up
|
|
||||||
Qx.transaction do
|
|
||||||
Qx.execute(%(
|
|
||||||
CREATE INDEX IF NOT EXISTS payments_date ON payments (date);
|
|
||||||
CREATE INDEX IF NOT EXISTS payments_gross_amount ON payments (gross_amount);
|
|
||||||
CREATE INDEX IF NOT EXISTS payments_kind ON payments (kind);
|
|
||||||
CREATE INDEX IF NOT EXISTS payments_towards ON payments (lower(towards));
|
|
||||||
CREATE INDEX IF NOT EXISTS payments_donation_id ON payments (donation_id);
|
|
||||||
CREATE INDEX IF NOT EXISTS payments_supporter_id ON payments (supporter_id);
|
|
||||||
CREATE INDEX IF NOT EXISTS payments_nonprofit_id ON payments (nonprofit_id);
|
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS supporters_created_at ON supporters (created_at) WHERE deleted != true;
|
|
||||||
CREATE INDEX IF NOT EXISTS supporters_name ON supporters (lower(name)) WHERE deleted != true;
|
|
||||||
CREATE INDEX IF NOT EXISTS supporters_email ON supporters (lower(email)) WHERE deleted != true;
|
|
||||||
CREATE INDEX IF NOT EXISTS supporters_nonprofit_id ON supporters (nonprofit_id) WHERE deleted != true;
|
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS donations_amount ON donations USING btree (amount);
|
|
||||||
CREATE INDEX IF NOT EXISTS donations_designation ON donations USING btree (lower(designation));
|
|
||||||
CREATE INDEX IF NOT EXISTS donations_supporter_id ON donations USING btree (supporter_id);
|
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS tag_joins_supporter_id ON tag_joins (supporter_id);
|
|
||||||
CREATE INDEX IF NOT EXISTS tag_joins_tag_master_id ON tag_joins (tag_master_id);
|
|
||||||
|
|
||||||
CREATE INDEX IF NOT EXISTS custom_field_joins_custom_field_master_id ON custom_field_joins (custom_field_master_id);
|
|
||||||
))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def down
|
|
||||||
Qx.execute(%(
|
|
||||||
DROP INDEX IF EXISTS payments_date;
|
|
||||||
DROP INDEX IF EXISTS payments_gross_amount;
|
|
||||||
DROP INDEX IF EXISTS payments_kind;
|
|
||||||
DROP INDEX IF EXISTS payments_towards;
|
|
||||||
DROP INDEX IF EXISTS payments_supporter_id;
|
|
||||||
DROP INDEX IF EXISTS payments_nonprofit_id;
|
|
||||||
|
|
||||||
DROP INDEX IF EXISTS supporters_created_at;
|
|
||||||
DROP INDEX IF EXISTS supporters_name;
|
|
||||||
DROP INDEX IF EXISTS supporters_email;
|
|
||||||
DROP INDEX IF EXISTS supporters_nonprofit_id;
|
|
||||||
DROP INDEX IF EXISTS supporters_donation_id;
|
|
||||||
|
|
||||||
DROP INDEX IF EXISTS donations_amount;
|
|
||||||
DROP INDEX IF EXISTS donations_designation;
|
|
||||||
DROP INDEX IF EXISTS donations_supporter_id;
|
|
||||||
|
|
||||||
DROP INDEX IF EXISTS tag_joins_supporter_id;
|
|
||||||
DROP INDEX IF EXISTS tag_joins_tag_master_id;
|
|
||||||
|
|
||||||
DROP INDEX IF EXISTS custom_field_joins_custom_field_master_id;
|
|
||||||
))
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,296 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class DropAllCruft < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
Qx.execute(%(
|
|
||||||
DROP FUNCTION IF EXISTS update_payment_donations_search_vectors();
|
|
||||||
DROP FUNCTION IF EXISTS supporters_insert_trigger();
|
|
||||||
DROP FUNCTION IF EXISTS update_payment_search_vectors();
|
|
||||||
DROP FUNCTION IF EXISTS update_payment_supporters_search_vectors();
|
|
||||||
DROP FUNCTION IF EXISTS update_supporter_search_vectors();
|
|
||||||
DROP TABLE IF EXISTS billing_customers;
|
|
||||||
DROP TABLE IF EXISTS coupons;
|
|
||||||
DROP TABLE IF EXISTS dedications;
|
|
||||||
DROP TABLE IF EXISTS email_drafts;
|
|
||||||
DROP TABLE IF EXISTS image_points;
|
|
||||||
DROP TABLE IF EXISTS pg_search_documents;
|
|
||||||
DROP TABLE IF EXISTS prospect_events;
|
|
||||||
DROP TABLE IF EXISTS prospect_visit_params;
|
|
||||||
DROP TABLE IF EXISTS prospect_visits;
|
|
||||||
DROP TABLE IF EXISTS prospects;
|
|
||||||
DROP TABLE IF EXISTS recommendations;
|
|
||||||
))
|
|
||||||
end
|
|
||||||
|
|
||||||
def down
|
|
||||||
Qx.execute(%(
|
|
||||||
CREATE FUNCTION update_payment_donations_search_vectors() RETURNS trigger
|
|
||||||
LANGUAGE plpgsql
|
|
||||||
AS $$ BEGIN
|
|
||||||
IF pg_trigger_depth() <> 1 THEN RETURN new; END IF;
|
|
||||||
UPDATE payments
|
|
||||||
SET search_vectors=to_tsvector('english', data.search_blob)
|
|
||||||
FROM (
|
|
||||||
SELECT payments.id, concat_ws(' '
|
|
||||||
, payments.gross_amount
|
|
||||||
, payments.kind
|
|
||||||
, payments.towards
|
|
||||||
, supporters.name
|
|
||||||
, supporters.organization
|
|
||||||
, supporters.email
|
|
||||||
, supporters.city
|
|
||||||
, supporters.state_code
|
|
||||||
, donations.designation
|
|
||||||
, donations.dedication
|
|
||||||
) AS search_blob
|
|
||||||
FROM payments
|
|
||||||
LEFT OUTER JOIN supporters
|
|
||||||
ON payments.supporter_id=supporters.id
|
|
||||||
LEFT OUTER JOIN donations
|
|
||||||
ON payments.donation_id=donations.id
|
|
||||||
WHERE (payments.donation_id=NEW.id)) AS data
|
|
||||||
WHERE data.id=payments.id;
|
|
||||||
RETURN new;
|
|
||||||
END $$;
|
|
||||||
))
|
|
||||||
|
|
||||||
Qx.execute(%(
|
|
||||||
CREATE FUNCTION supporters_insert_trigger() RETURNS trigger
|
|
||||||
LANGUAGE plpgsql
|
|
||||||
AS $$
|
|
||||||
BEGIN
|
|
||||||
INSERT INTO supporters_active VALUES(NEW.*);
|
|
||||||
RETURN NULL;
|
|
||||||
END; $$;
|
|
||||||
))
|
|
||||||
|
|
||||||
Qx.execute(%(
|
|
||||||
CREATE FUNCTION update_payment_search_vectors() RETURNS trigger
|
|
||||||
LANGUAGE plpgsql
|
|
||||||
AS $$ BEGIN
|
|
||||||
IF pg_trigger_depth() <> 1 THEN RETURN new; END IF;
|
|
||||||
UPDATE payments
|
|
||||||
SET search_vectors=to_tsvector('english', data.search_blob)
|
|
||||||
FROM (
|
|
||||||
SELECT payments.id, concat_ws(' '
|
|
||||||
, payments.gross_amount
|
|
||||||
, payments.kind
|
|
||||||
, payments.towards
|
|
||||||
, supporters.name
|
|
||||||
, supporters.organization
|
|
||||||
, supporters.email
|
|
||||||
, supporters.city
|
|
||||||
, supporters.state_code
|
|
||||||
, donations.designation
|
|
||||||
, donations.dedication
|
|
||||||
) AS search_blob
|
|
||||||
FROM payments
|
|
||||||
LEFT OUTER JOIN supporters
|
|
||||||
ON payments.supporter_id=supporters.id
|
|
||||||
LEFT OUTER JOIN donations
|
|
||||||
ON payments.donation_id=donations.id
|
|
||||||
WHERE (payments.id=NEW.id)) AS data
|
|
||||||
WHERE data.id=payments.id;
|
|
||||||
RETURN new;
|
|
||||||
END $$;
|
|
||||||
|
|
||||||
))
|
|
||||||
|
|
||||||
Qx.execute(%(
|
|
||||||
CREATE FUNCTION update_payment_supporters_search_vectors() RETURNS trigger
|
|
||||||
LANGUAGE plpgsql
|
|
||||||
AS $$ BEGIN
|
|
||||||
IF pg_trigger_depth() <> 1 THEN RETURN new; END IF;
|
|
||||||
UPDATE payments
|
|
||||||
SET search_vectors=to_tsvector('english', data.search_blob)
|
|
||||||
FROM (
|
|
||||||
SELECT payments.id, concat_ws(' '
|
|
||||||
, payments.gross_amount
|
|
||||||
, payments.kind
|
|
||||||
, payments.towards
|
|
||||||
, supporters.name
|
|
||||||
, supporters.organization
|
|
||||||
, supporters.email
|
|
||||||
, supporters.city
|
|
||||||
, supporters.state_code
|
|
||||||
, donations.designation
|
|
||||||
, donations.dedication
|
|
||||||
) AS search_blob
|
|
||||||
FROM payments
|
|
||||||
LEFT OUTER JOIN supporters
|
|
||||||
ON payments.supporter_id=supporters.id
|
|
||||||
LEFT OUTER JOIN donations
|
|
||||||
ON payments.donation_id=donations.id
|
|
||||||
WHERE (payments.supporter_id=NEW.id)) AS data
|
|
||||||
WHERE data.id=payments.id;
|
|
||||||
RETURN new;
|
|
||||||
END $$;
|
|
||||||
))
|
|
||||||
|
|
||||||
Qx.execute(%(
|
|
||||||
CREATE FUNCTION update_supporter_search_vectors() RETURNS trigger
|
|
||||||
LANGUAGE plpgsql
|
|
||||||
AS $$ BEGIN
|
|
||||||
IF pg_trigger_depth() <> 1 THEN RETURN new; END IF;
|
|
||||||
UPDATE supporters
|
|
||||||
SET search_vectors=to_tsvector('english', data.search_blob)
|
|
||||||
FROM (
|
|
||||||
SELECT supporters.id, concat_ws(' '
|
|
||||||
, custom_field_joins.value
|
|
||||||
, supporters.name
|
|
||||||
, supporters.organization
|
|
||||||
, supporters.id
|
|
||||||
, supporters.email
|
|
||||||
, supporters.city
|
|
||||||
, supporters.state_code
|
|
||||||
, donations.designation
|
|
||||||
, donations.dedication
|
|
||||||
, payments.kind
|
|
||||||
, payments.towards
|
|
||||||
) AS search_blob
|
|
||||||
FROM supporters
|
|
||||||
LEFT OUTER JOIN payments
|
|
||||||
ON payments.supporter_id=supporters.id
|
|
||||||
LEFT OUTER JOIN donations
|
|
||||||
ON donations.supporter_id=supporters.id
|
|
||||||
LEFT OUTER JOIN (
|
|
||||||
SELECT string_agg(value::text, ' ') AS value, supporter_id
|
|
||||||
FROM custom_field_joins
|
|
||||||
GROUP BY supporter_id) AS custom_field_joins
|
|
||||||
ON custom_field_joins.supporter_id=supporters.id
|
|
||||||
WHERE (supporters.id=NEW.id)) AS data
|
|
||||||
WHERE data.id=supporters.id;
|
|
||||||
RETURN new;
|
|
||||||
END $$;
|
|
||||||
))
|
|
||||||
|
|
||||||
Qx.execute(%(
|
|
||||||
CREATE TABLE billing_customers (
|
|
||||||
id integer NOT NULL,
|
|
||||||
card_name character varying(255),
|
|
||||||
stripe_customer_id character varying(255),
|
|
||||||
nonprofit_id integer,
|
|
||||||
created_at timestamp without time zone NOT NULL,
|
|
||||||
updated_at timestamp without time zone NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
))
|
|
||||||
|
|
||||||
Qx.execute(%(
|
|
||||||
CREATE TABLE coupons (
|
|
||||||
id integer NOT NULL,
|
|
||||||
name character varying(255),
|
|
||||||
paid boolean,
|
|
||||||
victim_np_id integer,
|
|
||||||
nonprofit_id integer,
|
|
||||||
created_at timestamp without time zone NOT NULL,
|
|
||||||
updated_at timestamp without time zone NOT NULL
|
|
||||||
);
|
|
||||||
))
|
|
||||||
|
|
||||||
Qx.execute(%(
|
|
||||||
CREATE TABLE dedications (
|
|
||||||
id integer NOT NULL,
|
|
||||||
donation_id integer,
|
|
||||||
supporter_id integer,
|
|
||||||
created_at timestamp without time zone NOT NULL,
|
|
||||||
updated_at timestamp without time zone NOT NULL
|
|
||||||
);
|
|
||||||
))
|
|
||||||
|
|
||||||
Qx.execute(%(
|
|
||||||
CREATE TABLE email_drafts (
|
|
||||||
id integer NOT NULL,
|
|
||||||
nonprofit_id integer,
|
|
||||||
name character varying(255),
|
|
||||||
value text,
|
|
||||||
deleted boolean,
|
|
||||||
created_at timestamp without time zone NOT NULL,
|
|
||||||
updated_at timestamp without time zone NOT NULL
|
|
||||||
);
|
|
||||||
))
|
|
||||||
|
|
||||||
Qx.execute(%(
|
|
||||||
CREATE TABLE image_points (
|
|
||||||
id integer NOT NULL,
|
|
||||||
image_name character varying(255),
|
|
||||||
host_id integer,
|
|
||||||
host_type character varying(255),
|
|
||||||
x double precision,
|
|
||||||
y double precision,
|
|
||||||
preview_left character varying(255),
|
|
||||||
preview_top character varying(255),
|
|
||||||
created_at timestamp without time zone NOT NULL,
|
|
||||||
updated_at timestamp without time zone NOT NULL
|
|
||||||
);
|
|
||||||
))
|
|
||||||
|
|
||||||
Qx.execute(%(
|
|
||||||
CREATE TABLE pg_search_documents (
|
|
||||||
id integer NOT NULL,
|
|
||||||
content text,
|
|
||||||
searchable_id integer,
|
|
||||||
searchable_type character varying(255),
|
|
||||||
created_at timestamp without time zone NOT NULL,
|
|
||||||
updated_at timestamp without time zone NOT NULL
|
|
||||||
);
|
|
||||||
|
|
||||||
))
|
|
||||||
|
|
||||||
Qx.execute(%(
|
|
||||||
CREATE TABLE prospect_events (
|
|
||||||
id integer NOT NULL,
|
|
||||||
event character varying(255),
|
|
||||||
prospect_visit_id integer,
|
|
||||||
prospect_id integer,
|
|
||||||
created_at timestamp without time zone NOT NULL,
|
|
||||||
updated_at timestamp without time zone NOT NULL
|
|
||||||
);
|
|
||||||
))
|
|
||||||
|
|
||||||
Qx.execute(%(
|
|
||||||
CREATE TABLE prospect_visit_params (
|
|
||||||
id integer NOT NULL,
|
|
||||||
key character varying(255),
|
|
||||||
val character varying(255),
|
|
||||||
prospect_visit_id integer
|
|
||||||
);
|
|
||||||
))
|
|
||||||
|
|
||||||
Qx.execute(%(
|
|
||||||
CREATE TABLE prospect_visits (
|
|
||||||
id integer NOT NULL,
|
|
||||||
pathname text,
|
|
||||||
prospect_id integer,
|
|
||||||
created_at timestamp without time zone NOT NULL,
|
|
||||||
updated_at timestamp without time zone NOT NULL
|
|
||||||
);
|
|
||||||
))
|
|
||||||
|
|
||||||
Qx.execute(%(
|
|
||||||
CREATE TABLE prospects (
|
|
||||||
id integer NOT NULL,
|
|
||||||
ip_address character varying(255),
|
|
||||||
referrer_url text,
|
|
||||||
user_id integer,
|
|
||||||
created_at timestamp without time zone NOT NULL,
|
|
||||||
updated_at timestamp without time zone NOT NULL,
|
|
||||||
email character varying(255),
|
|
||||||
session_id character varying(255),
|
|
||||||
cookie_id character varying(255)
|
|
||||||
);
|
|
||||||
))
|
|
||||||
|
|
||||||
Qx.execute(%(
|
|
||||||
CREATE TABLE recommendations (
|
|
||||||
id integer NOT NULL,
|
|
||||||
nonprofit_id integer,
|
|
||||||
profile_id integer,
|
|
||||||
content text,
|
|
||||||
created_at timestamp without time zone NOT NULL,
|
|
||||||
updated_at timestamp without time zone NOT NULL
|
|
||||||
);
|
|
||||||
))
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,42 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class NormalizeStartAndEndDatetimesForEventsAndCampaigns < ActiveRecord::Migration[4.2]
|
|
||||||
def up
|
|
||||||
add_column :events, :start_datetime, :datetime
|
|
||||||
add_column :events, :end_datetime, :datetime
|
|
||||||
add_column :campaigns, :end_datetime, :datetime
|
|
||||||
Qx.update(:events)
|
|
||||||
.set(%(start_datetime = ("date" + start_time), end_datetime = ("date" + end_time)))
|
|
||||||
.where("created_at > '2012-01-01'")
|
|
||||||
.execute
|
|
||||||
Qx.update(:campaigns)
|
|
||||||
.set('end_datetime = (expiration + end_time)')
|
|
||||||
.where("created_at > '2012-01-01'")
|
|
||||||
.execute
|
|
||||||
remove_column :events, :end_time
|
|
||||||
remove_column :events, :start_time
|
|
||||||
remove_column :events, :date
|
|
||||||
remove_column :campaigns, :expiration
|
|
||||||
remove_column :campaigns, :end_time
|
|
||||||
end
|
|
||||||
|
|
||||||
def down
|
|
||||||
add_column :events, :end_time, :time
|
|
||||||
add_column :events, :start_time, :time
|
|
||||||
add_column :events, :date, :date
|
|
||||||
add_column :campaigns, :expiration, :date
|
|
||||||
add_column :campaigns, :end_time, :time
|
|
||||||
Qx.update(:events)
|
|
||||||
.set(%(end_time = end_datetime::time, start_time = start_datetime::time, "date" = start_datetime::date))
|
|
||||||
.where("created_at > '2012-01-01'")
|
|
||||||
.execute
|
|
||||||
Qx.update(:campaigns)
|
|
||||||
.set('end_time = end_datetime::time, expiration = end_datetime::date')
|
|
||||||
.where("created_at > '2012-01-01'")
|
|
||||||
.execute
|
|
||||||
remove_column :events, :start_datetime
|
|
||||||
remove_column :events, :end_datetime
|
|
||||||
remove_column :campaigns, :end_datetime
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,18 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class AddDonationCampaignIdIndex < ActiveRecord::Migration[4.2]
|
|
||||||
def up
|
|
||||||
Qx.execute(%(
|
|
||||||
CREATE INDEX IF NOT EXISTS donations_campaign_id ON donations (campaign_id);
|
|
||||||
CREATE INDEX IF NOT EXISTS donations_event_id ON donations (event_id);
|
|
||||||
))
|
|
||||||
end
|
|
||||||
|
|
||||||
def down
|
|
||||||
Qx.execute(%(
|
|
||||||
DROP INDEX IF EXISTS donations_campaign_id;
|
|
||||||
DROP INDEX IF EXISTS donations_event_id;
|
|
||||||
))
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,18 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class AddTheTagJoinsBackupTable < ActiveRecord::Migration[4.2]
|
|
||||||
def up
|
|
||||||
create_table :tag_joins_backup do |t|
|
|
||||||
t.integer 'tag_master_id'
|
|
||||||
t.integer 'supporter_id'
|
|
||||||
t.datetime 'created_at'
|
|
||||||
t.datetime 'updated_at'
|
|
||||||
t.text 'metadata'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def down
|
|
||||||
drop_table :tag_joins_backup
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,15 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class AddIndexForTagJoinsAndAddConstraint < ActiveRecord::Migration[4.2]
|
|
||||||
def up
|
|
||||||
ids = DeleteTagJoins.find_multiple_tag_joins
|
|
||||||
DeleteTagJoins.copy_and_delete(ids)
|
|
||||||
add_index :tag_joins, %i[tag_master_id supporter_id], unique: true, name: 'tag_join_supporter_unique_idx'
|
|
||||||
end
|
|
||||||
|
|
||||||
def down
|
|
||||||
remove_index(:tag_joins, name: 'tag_join_supporter_unique_idx')
|
|
||||||
DeleteTagJoins.revert
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,14 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class AddCustomFieldJoinsBackupTable < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
create_table :custom_field_joins_backup do |t|
|
|
||||||
t.integer 'custom_field_master_id'
|
|
||||||
t.integer 'supporter_id'
|
|
||||||
t.text 'metadata'
|
|
||||||
t.text 'value'
|
|
||||||
t.timestamps
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,15 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class AddIndexForCustomFieldJoinAndSupporters < ActiveRecord::Migration[4.2]
|
|
||||||
def up
|
|
||||||
ids = DeleteCustomFieldJoins.find_multiple_custom_field_joins
|
|
||||||
DeleteCustomFieldJoins.copy_and_delete(ids)
|
|
||||||
add_index :custom_field_joins, %i[custom_field_master_id supporter_id], unique: true, name: 'custom_field_join_supporter_unique_idx'
|
|
||||||
end
|
|
||||||
|
|
||||||
def down
|
|
||||||
remove_index(:custom_field_joins, name: 'custom_field_join_supporter_unique_idx')
|
|
||||||
DeleteCustomFieldJoins.revert
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,15 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class AddInactiveToCard < ActiveRecord::Migration[4.2]
|
|
||||||
class Card < ActiveRecord::Base
|
|
||||||
attr_accessible :inactive
|
|
||||||
end
|
|
||||||
def change
|
|
||||||
add_column :cards, :inactive, :boolean
|
|
||||||
|
|
||||||
add_index :cards, %i[id holder_type holder_id inactive] # add index for getting active_card
|
|
||||||
Card.reset_column_information
|
|
||||||
Card.update_all(inactive: false)
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,22 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class CreateExports < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
create_table :exports do |t|
|
|
||||||
t.integer :user_id
|
|
||||||
t.integer :nonprofit_id
|
|
||||||
t.string :status
|
|
||||||
t.string :exception
|
|
||||||
t.datetime :ended
|
|
||||||
t.string :export_type
|
|
||||||
t.string :parameters
|
|
||||||
t.string :url
|
|
||||||
|
|
||||||
t.timestamps
|
|
||||||
end
|
|
||||||
|
|
||||||
add_index :exports, :user_id
|
|
||||||
add_index :exports, :nonprofit_id
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,12 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class CreateMiscellaneousNpInfos < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
create_table :miscellaneous_np_infos do |t|
|
|
||||||
t.string :donate_again_url
|
|
||||||
t.belongs_to :nonprofit
|
|
||||||
t.timestamps
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,8 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class AddCurrencyToNonprofit < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
add_column :nonprofits, :currency, :string, default: Settings.intntl.currencies[0]
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,8 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class AddChangeAmountMessageToMiscellaneousNpInfos < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
add_column :miscellaneous_np_infos, :change_amount_message, :text
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,9 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class AddFirstAndLastNameToSupporter < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
add_column :supporters, :first_name, :string
|
|
||||||
add_column :supporters, :last_name, :string
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,14 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class AddTracking < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
create_table :trackings do |t|
|
|
||||||
t.column :utm_campaign, :string, unique: true
|
|
||||||
t.column :utm_medium, :string, unique: true
|
|
||||||
t.column :utm_source, :string, unique: true
|
|
||||||
t.belongs_to :donation, index: true
|
|
||||||
t.timestamps
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,8 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class AddQueuedForImportAtToDonation < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
add_column :donations, :queued_for_import_at, :datetime, default: nil
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,21 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class AddDirectDebitDetail < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
create_table :direct_debit_details do |t|
|
|
||||||
t.string :iban
|
|
||||||
t.string :account_holder_name
|
|
||||||
t.string :bic
|
|
||||||
t.belongs_to :supporter, index: true
|
|
||||||
|
|
||||||
t.timestamps
|
|
||||||
end
|
|
||||||
|
|
||||||
add_column :donations,
|
|
||||||
:direct_debit_detail_id,
|
|
||||||
:integer,
|
|
||||||
index: true,
|
|
||||||
references: :direct_debit_details
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,8 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class AddUtmContentToTrackings < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
add_column :trackings, :utm_content, :string, unique: true
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,8 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class AddLocaleToSupporters < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
add_column :supporters, :locale, :string
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,8 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class AddPaymentProviderToDonations < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
add_column :donations, :payment_provider, :string
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,8 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class AddDirectDebitDetailToCharges < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
add_column :charges, :direct_debit_detail_id, :integer
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,8 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class AddExternalIdentifierToCampaign < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
add_column :campaigns, :external_identifier, :string
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,8 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class AddIndexToCampaignGifts < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
add_index :campaign_gifts, :campaign_gift_option_id
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,9 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class AddIndexToActivities < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
add_index :activities, :supporter_id
|
|
||||||
add_index :activities, :nonprofit_id
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,12 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class ModifySupportersNameIndex < ActiveRecord::Migration[4.2]
|
|
||||||
def up
|
|
||||||
rename_index :supporters, :supporters_name, :supporters_lower_name
|
|
||||||
end
|
|
||||||
|
|
||||||
def down
|
|
||||||
rename_index :supporters, :supporters_lower_name, :supporters_name
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,8 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class AddSupportersNameIndex < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
add_index :supporters, :name
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,8 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class AddChargesPaymentIdIndex < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
add_index :charges, :payment_id
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,9 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class AddIndexesForSupporterDeletedAndImport < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
add_index :supporters, :deleted
|
|
||||||
add_index :supporters, :import_id
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,13 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class CreatePaymentImports < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
create_table :payment_imports do |t|
|
|
||||||
t.references :user
|
|
||||||
t.references :nonprofit
|
|
||||||
|
|
||||||
t.timestamps
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,11 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class CreateDonationsPaymentImportsJoinTable < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
create_table :donations_payment_imports, id: false do |t|
|
|
||||||
t.references :donation
|
|
||||||
t.references :payment_import
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,48 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class RemoveUnusedMetadata < ActiveRecord::Migration[4.2]
|
|
||||||
TABLES = %i[
|
|
||||||
campaign_gift_options
|
|
||||||
campaign_gifts
|
|
||||||
campaigns
|
|
||||||
cards
|
|
||||||
charges
|
|
||||||
custom_field_masters
|
|
||||||
custom_field_joins
|
|
||||||
disputes
|
|
||||||
donations
|
|
||||||
events
|
|
||||||
imports
|
|
||||||
nonprofits
|
|
||||||
offsite_payments
|
|
||||||
payments
|
|
||||||
payment_payouts
|
|
||||||
payouts
|
|
||||||
profiles
|
|
||||||
recurring_donations
|
|
||||||
refunds
|
|
||||||
roles
|
|
||||||
supporter_emails
|
|
||||||
supporter_notes
|
|
||||||
supporters
|
|
||||||
tag_joins
|
|
||||||
tag_masters
|
|
||||||
ticket_levels
|
|
||||||
tickets
|
|
||||||
users
|
|
||||||
].freeze
|
|
||||||
FIELDS = %i[id metadata].freeze
|
|
||||||
|
|
||||||
def up
|
|
||||||
TABLES.each do |table|
|
|
||||||
remove_column table, :metadata
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def down
|
|
||||||
TABLES.each do |table|
|
|
||||||
add_column table, :metadata, :text
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,10 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class RemoveRecurringDonationEventId < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
change_table :recurring_donations do |t|
|
|
||||||
t.remove :event_id
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,20 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class CreateSourceTokens < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
create_table :source_tokens, id: false do |t|
|
|
||||||
t.column :token, 'uuid', primary_key: true, null: false
|
|
||||||
t.datetime :expiration
|
|
||||||
t.references :tokenizable, polymorphic: true
|
|
||||||
t.references :event
|
|
||||||
t.integer :max_uses, default: 1
|
|
||||||
t.integer :total_uses, default: 0
|
|
||||||
t.timestamps
|
|
||||||
end
|
|
||||||
|
|
||||||
add_index :source_tokens, :token, unique: true
|
|
||||||
add_index :source_tokens, :expiration
|
|
||||||
add_index :source_tokens, %i[tokenizable_id tokenizable_type]
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,12 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class AddCardTokenToTicket < ActiveRecord::Migration[4.2]
|
|
||||||
def up
|
|
||||||
add_column :tickets, :source_token_id, 'uuid'
|
|
||||||
end
|
|
||||||
|
|
||||||
def down
|
|
||||||
remove_column :tickets, :source_token_id
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,7 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class AddIndexesToSupporterNotes < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
add_index :supporter_notes, :supporter_id, order: { supporter_id: :asc }
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,8 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class ChangeDddSupporterToHolder < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
rename_column :direct_debit_details, :supporter_id, :holder_id
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,10 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
|
||||||
class RemoveArticles < ActiveRecord::Migration[4.2]
|
|
||||||
def up
|
|
||||||
drop_table :articles
|
|
||||||
end
|
|
||||||
|
|
||||||
def down; end
|
|
||||||
end
|
|
|
@ -1,7 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class AddIndexToSupporterIdOnTickets < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
add_index :tickets, :supporter_id
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,8 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class AddIndexToEventIdOnDonationsAndEvents < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
add_index :tickets, :event_id
|
|
||||||
add_index :donations, :event_id
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,7 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class AddParentCampaignIdToCampaigns < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
add_column :campaigns, :parent_campaign_id, :integer
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,7 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class AddReasonForSupportingToCampaigns < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
add_column :campaigns, :reason_for_supporting, :text
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,7 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class AddDefaultReasonForSupportingToCampaigns < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
add_column :campaigns, :default_reason_for_supporting, :text
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,7 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class AddBannerImageToCampaigns < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
add_column :campaigns, :banner_image, :string
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,7 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class AddChargeIdIndexes < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
add_index :refunds, :charge_id
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,7 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class AddPaymentIdToTickets < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
add_index :tickets, :payment_id
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,7 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class AddIndexesToRefunds < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
add_index :refunds, :payment_id
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,30 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class CorrectDedications < ActiveRecord::Migration[4.2]
|
|
||||||
def up
|
|
||||||
execute <<~SQL
|
|
||||||
create or replace function is_valid_json(p_json text)
|
|
||||||
returns boolean
|
|
||||||
as
|
|
||||||
$$
|
|
||||||
begin
|
|
||||||
return (p_json::json is not null);
|
|
||||||
exception
|
|
||||||
when others then
|
|
||||||
return false;
|
|
||||||
end;
|
|
||||||
$$
|
|
||||||
language plpgsql
|
|
||||||
immutable;
|
|
||||||
SQL
|
|
||||||
|
|
||||||
dedications = MaintainDedications.retrieve_non_json_dedications
|
|
||||||
|
|
||||||
MaintainDedications.create_json_dedications_from_plain_text(dedications)
|
|
||||||
|
|
||||||
dedications = MaintainDedications.retrieve_json_dedications
|
|
||||||
MaintainDedications.add_honor_to_any_json_dedications_without_type(dedications)
|
|
||||||
end
|
|
||||||
|
|
||||||
def down; end
|
|
||||||
end
|
|
|
@ -1,55 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class CorrectDedicationContacts < ActiveRecord::Migration[4.2]
|
|
||||||
def up
|
|
||||||
json_dedications = Qx.select('id', 'dedication').from(:donations)
|
|
||||||
.where("dedication IS NOT NULL AND dedication != ''")
|
|
||||||
.and_where('is_valid_json(dedication)').ex
|
|
||||||
parsed_dedications = json_dedications.map { |i| { id: i['id'], dedication: JSON.parse(i['dedication']) } }
|
|
||||||
with_contact_to_correct = parsed_dedications.select { |i| !i[:dedication]['contact'].blank? && i[:dedication]['contact'].is_a?(String) }
|
|
||||||
really_icky_dedications, easy_to_split_strings = with_contact_to_correct.partition { |i| i[:dedication]['contact'].split(' - ').count > 3 }
|
|
||||||
|
|
||||||
easy_to_split_strings.map do |i|
|
|
||||||
split_contact = i[:dedication]['contact'].split(' - ')
|
|
||||||
i[:dedication]['contact'] = {
|
|
||||||
email: split_contact[0],
|
|
||||||
phone: split_contact[1],
|
|
||||||
address: split_contact[2]
|
|
||||||
}
|
|
||||||
puts i
|
|
||||||
i
|
|
||||||
end.each_with_index do |i, index|
|
|
||||||
unless i[:id]
|
|
||||||
raise Error("Item at index #{index} is invalid. Object:#{i}")
|
|
||||||
end
|
|
||||||
|
|
||||||
Qx.update(:donations).where('id = $id', id: i[:id]).set(dedication: JSON.generate(i[:dedication])).ex
|
|
||||||
end
|
|
||||||
|
|
||||||
puts "Corrected #{easy_to_split_strings.count} records."
|
|
||||||
|
|
||||||
puts ''
|
|
||||||
puts ''
|
|
||||||
puts 'You must manually fix the following dedications: '
|
|
||||||
really_icky_dedications.each do |i|
|
|
||||||
puts i
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def down
|
|
||||||
json_dedications = Qx.select('id', 'dedication').from(:donations)
|
|
||||||
.where("dedication IS NOT NULL AND dedication != ''")
|
|
||||||
.and_where('is_valid_json(dedication)').ex
|
|
||||||
|
|
||||||
parsed_dedications = json_dedications.map { |i| { 'id' => i['id'], 'dedication' => JSON.parse(i['dedication']) } }
|
|
||||||
|
|
||||||
with_contact_to_correct = parsed_dedications.select { |i| i['dedication']['contact'].is_a?(Hash) }
|
|
||||||
|
|
||||||
puts "#{with_contact_to_correct.count} to revert"
|
|
||||||
with_contact_to_correct.each do |i|
|
|
||||||
contact_string = "#{i['dedication']['contact']['email']} - #{i['dedication']['contact']['phone']} - #{i['dedication']['contact']['address']}"
|
|
||||||
i['dedication']['contact'] = contact_string
|
|
||||||
Qx.update(:donations).where('id = $id', id: i['id']).set(dedication: JSON.generate(i['dedication'])).ex
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,7 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class AddIndexParentCampaignIdToCampaign < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
add_index :campaigns, :parent_campaign_id
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,7 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class AddIndexesToRecurringDonations < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
add_index :recurring_donations, :donation_id
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,7 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class AddDonationIdIndexToCampaignGifts < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
add_index :campaign_gifts, :donation_id
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,7 +0,0 @@
|
||||||
# frozen_string_literal: true
|
|
||||||
|
|
||||||
class AddIndexToPaymentsCreatedAt < ActiveRecord::Migration[4.2]
|
|
||||||
def change
|
|
||||||
add_index :payments, :created_at
|
|
||||||
end
|
|
||||||
end
|
|
Loading…
Reference in a new issue