Skip to content

Instantly share code, notes, and snippets.

@therefromhere
Created March 10, 2019 05:43
Show Gist options
  • Save therefromhere/d51890fea89e662692a58a1a261ab315 to your computer and use it in GitHub Desktop.
Save therefromhere/d51890fea89e662692a58a1a261ab315 to your computer and use it in GitHub Desktop.
BEGIN;
--
-- Alter field display_name on account
--
--
-- Alter field support_email on account
--
--
-- Alter field support_phone on account
--
--
-- Alter field customer on card
--
SET CONSTRAINTS "djstripe_card_customer_id_9601f29c_fk_djstripe_" IMMEDIATE; ALTER TABLE "djstripe_card" DROP CONSTRAINT "djstripe_card_customer_id_9601f29c_fk_djstripe_";
ALTER TABLE "djstripe_card" ALTER COLUMN "customer_id" DROP NOT NULL;
ALTER TABLE "djstripe_card" ADD CONSTRAINT "djstripe_card_customer_id_9601f29c_fk_djstripe_" FOREIGN KEY ("customer_id") REFERENCES "djstripe_customer" ("djstripe_id") DEFERRABLE INITIALLY DEFERRED;
--
-- Add field name to coupon
--
ALTER TABLE "djstripe_coupon" ADD COLUMN "name" text DEFAULT '' NOT NULL;
ALTER TABLE "djstripe_coupon" ALTER COLUMN "name" DROP DEFAULT;
--
-- Alter field type on source
--
ALTER TABLE "djstripe_source" ALTER COLUMN "type" TYPE varchar(20) USING "type"::varchar(20);
--
-- Add field active to plan
--
ALTER TABLE "djstripe_plan" ADD COLUMN "active" boolean DEFAULT true NOT NULL;
ALTER TABLE "djstripe_plan" ALTER COLUMN "active" DROP DEFAULT;
--
-- Remove field fraudulent from charge
--
ALTER TABLE "djstripe_charge" DROP COLUMN "fraudulent" CASCADE;
--
-- Remove field receipt_sent from charge
--
ALTER TABLE "djstripe_charge" DROP COLUMN "receipt_sent" CASCADE;
--
-- Remove field source_stripe_id from charge
--
ALTER TABLE "djstripe_charge" DROP COLUMN "source_stripe_id" CASCADE;
--
-- Remove field source_type from charge
--
ALTER TABLE "djstripe_charge" DROP COLUMN "source_type" CASCADE;
--
-- Remove field fee from charge
--
ALTER TABLE "djstripe_charge" DROP COLUMN "fee" CASCADE;
--
-- Remove field fee_details from charge
--
ALTER TABLE "djstripe_charge" DROP COLUMN "fee_details" CASCADE;
--
-- Remove field date from transfer
--
ALTER TABLE "djstripe_transfer" DROP COLUMN "date" CASCADE;
--
-- Remove field destination_type from transfer
--
ALTER TABLE "djstripe_transfer" DROP COLUMN "destination_type" CASCADE;
--
-- Remove field failure_code from transfer
--
ALTER TABLE "djstripe_transfer" DROP COLUMN "failure_code" CASCADE;
--
-- Remove field failure_message from transfer
--
ALTER TABLE "djstripe_transfer" DROP COLUMN "failure_message" CASCADE;
--
-- Remove field fee from transfer
--
ALTER TABLE "djstripe_transfer" DROP COLUMN "fee" CASCADE;
--
-- Remove field fee_details from transfer
--
ALTER TABLE "djstripe_transfer" DROP COLUMN "fee_details" CASCADE;
--
-- Remove field statement_descriptor from transfer
--
ALTER TABLE "djstripe_transfer" DROP COLUMN "statement_descriptor" CASCADE;
--
-- Remove field status from transfer
--
ALTER TABLE "djstripe_transfer" DROP COLUMN "status" CASCADE;
--
-- Change Meta options on account
--
--
-- Change Meta options on bankaccount
--
--
-- Change Meta options on card
--
--
-- Change Meta options on charge
--
--
-- Change Meta options on dispute
--
--
-- Change Meta options on event
--
--
-- Change Meta options on fileupload
--
--
-- Change Meta options on invoiceitem
--
--
-- Change Meta options on payout
--
--
-- Change Meta options on product
--
--
-- Change Meta options on refund
--
--
-- Change Meta options on source
--
--
-- Change Meta options on subscription
--
--
-- Change Meta options on transfer
--
--
-- Change Meta options on upcominginvoice
--
--
-- Create model CountrySpec
--
CREATE TABLE "djstripe_countryspec" ("djstripe_created" timestamp with time zone NOT NULL, "djstripe_updated" timestamp with time zone NOT NULL, "id" varchar(2) NOT NULL PRIMARY KEY, "default_currency" varchar(3) NOT NULL, "supported_bank_account_currencies" text NOT NULL, "supported_payment_currencies" text NOT NULL, "supported_payment_methods" text NOT NULL, "supported_transfer_countries" text NOT NULL, "verification_fields" text NOT NULL);
--
-- Create model BalanceTransaction
--
CREATE TABLE "djstripe_balancetransaction" ("djstripe_id" bigserial NOT NULL PRIMARY KEY, "id" varchar(255) NOT NULL UNIQUE, "livemode" boolean NULL, "created" timestamp with time zone NULL, "metadata" text NULL, "description" text NULL, "djstripe_created" timestamp with time zone NOT NULL, "djstripe_updated" timestamp with time zone NOT NULL, "amount" integer NOT NULL, "available_on" timestamp with time zone NOT NULL, "currency" varchar(3) NOT NULL, "exchange_rate" numeric(8, 6) NULL, "fee" integer NOT NULL, "fee_details" text NOT NULL, "net" integer NOT NULL, "status" varchar(9) NOT NULL, "type" varchar(22) NOT NULL);
--
-- Create model ScheduledQueryRun
--
CREATE TABLE "djstripe_scheduledqueryrun" ("djstripe_id" bigserial NOT NULL PRIMARY KEY, "id" varchar(255) NOT NULL UNIQUE, "livemode" boolean NULL, "created" timestamp with time zone NULL, "metadata" text NULL, "description" text NULL, "djstripe_created" timestamp with time zone NOT NULL, "djstripe_updated" timestamp with time zone NOT NULL, "data_load_time" timestamp with time zone NOT NULL, "error" text NULL, "result_available_until" timestamp with time zone NOT NULL, "sql" text NOT NULL, "status" varchar(9) NOT NULL, "title" text NOT NULL, "file_id" bigint NULL);
--
-- Create model SubscriptionItem
--
CREATE TABLE "djstripe_subscriptionitem" ("djstripe_id" bigserial NOT NULL PRIMARY KEY, "id" varchar(255) NOT NULL UNIQUE, "livemode" boolean NULL, "created" timestamp with time zone NULL, "metadata" text NULL, "description" text NULL, "djstripe_created" timestamp with time zone NOT NULL, "djstripe_updated" timestamp with time zone NOT NULL, "quantity" integer NOT NULL CHECK ("quantity" >= 0), "plan_id" bigint NOT NULL, "subscription_id" bigint NOT NULL);
--
-- Create model TransferReversal
--
CREATE TABLE "djstripe_transferreversal" ("djstripe_id" bigserial NOT NULL PRIMARY KEY, "id" varchar(255) NOT NULL UNIQUE, "livemode" boolean NULL, "created" timestamp with time zone NULL, "metadata" text NULL, "description" text NULL, "djstripe_created" timestamp with time zone NOT NULL, "djstripe_updated" timestamp with time zone NOT NULL, "amount" integer NOT NULL, "currency" varchar(3) NOT NULL, "balance_transaction_id" bigint NULL, "transfer_id" bigint NOT NULL);
--
-- Create model UsageRecord
--
CREATE TABLE "djstripe_usagerecord" ("djstripe_id" bigserial NOT NULL PRIMARY KEY, "id" varchar(255) NOT NULL UNIQUE, "livemode" boolean NULL, "created" timestamp with time zone NULL, "metadata" text NULL, "description" text NULL, "djstripe_created" timestamp with time zone NOT NULL, "djstripe_updated" timestamp with time zone NOT NULL, "quantity" integer NOT NULL CHECK ("quantity" >= 0), "subscription_item_id" bigint NOT NULL);
--
-- Create model ApplicationFee
--
CREATE TABLE "djstripe_applicationfee" ("djstripe_id" bigserial NOT NULL PRIMARY KEY, "id" varchar(255) NOT NULL UNIQUE, "livemode" boolean NULL, "created" timestamp with time zone NULL, "metadata" text NULL, "description" text NULL, "djstripe_created" timestamp with time zone NOT NULL, "djstripe_updated" timestamp with time zone NOT NULL, "amount" integer NOT NULL, "amount_refunded" integer NOT NULL, "currency" varchar(3) NOT NULL, "refunded" boolean NOT NULL, "balance_transaction_id" bigint NOT NULL, "charge_id" bigint NOT NULL);
--
-- Create model ApplicationFeeRefund
--
CREATE TABLE "djstripe_applicationfeerefund" ("djstripe_id" bigserial NOT NULL PRIMARY KEY, "id" varchar(255) NOT NULL UNIQUE, "livemode" boolean NULL, "created" timestamp with time zone NULL, "metadata" text NULL, "djstripe_created" timestamp with time zone NOT NULL, "djstripe_updated" timestamp with time zone NOT NULL, "amount" integer NOT NULL, "currency" varchar(3) NOT NULL, "balance_transaction_id" bigint NOT NULL, "fee_id" bigint NOT NULL);
--
-- Add field balance_transaction to charge
--
ALTER TABLE "djstripe_charge" ADD COLUMN "balance_transaction_id" bigint NULL;
--
-- Add field balance_transaction to payout
--
ALTER TABLE "djstripe_payout" ADD COLUMN "balance_transaction_id" bigint NULL;
--
-- Add field failure_balance_transaction to payout
--
ALTER TABLE "djstripe_payout" ADD COLUMN "failure_balance_transaction_id" bigint NULL;
--
-- Add field balance_transaction to refund
--
ALTER TABLE "djstripe_refund" ADD COLUMN "balance_transaction_id" bigint NULL;
--
-- Add field failure_balance_transaction to refund
--
ALTER TABLE "djstripe_refund" ADD COLUMN "failure_balance_transaction_id" bigint NULL;
--
-- Add field balance_transaction to transfer
--
ALTER TABLE "djstripe_transfer" ADD COLUMN "balance_transaction_id" bigint NULL;
--
-- Rename field stripe_id on account to id
--
ALTER TABLE "djstripe_account" RENAME COLUMN "stripe_id" TO "id";
--
-- Rename field stripe_id on bankaccount to id
--
ALTER TABLE "djstripe_bankaccount" RENAME COLUMN "stripe_id" TO "id";
--
-- Rename field stripe_id on card to id
--
ALTER TABLE "djstripe_card" RENAME COLUMN "stripe_id" TO "id";
--
-- Rename field stripe_id on charge to id
--
ALTER TABLE "djstripe_charge" RENAME COLUMN "stripe_id" TO "id";
--
-- Rename field stripe_id on customer to id
--
ALTER TABLE "djstripe_customer" RENAME COLUMN "stripe_id" TO "id";
--
-- Rename field stripe_id on dispute to id
--
ALTER TABLE "djstripe_dispute" RENAME COLUMN "stripe_id" TO "id";
--
-- Rename field stripe_id on event to id
--
ALTER TABLE "djstripe_event" RENAME COLUMN "stripe_id" TO "id";
--
-- Rename field stripe_id on fileupload to id
--
ALTER TABLE "djstripe_fileupload" RENAME COLUMN "stripe_id" TO "id";
--
-- Rename field stripe_id on invoice to id
--
ALTER TABLE "djstripe_invoice" RENAME COLUMN "stripe_id" TO "id";
--
-- Rename field stripe_id on invoiceitem to id
--
ALTER TABLE "djstripe_invoiceitem" RENAME COLUMN "stripe_id" TO "id";
--
-- Rename field stripe_id on payout to id
--
ALTER TABLE "djstripe_payout" RENAME COLUMN "stripe_id" TO "id";
--
-- Rename field stripe_id on plan to id
--
ALTER TABLE "djstripe_plan" RENAME COLUMN "stripe_id" TO "id";
--
-- Rename field stripe_id on product to id
--
ALTER TABLE "djstripe_product" RENAME COLUMN "stripe_id" TO "id";
--
-- Rename field stripe_id on refund to id
--
ALTER TABLE "djstripe_refund" RENAME COLUMN "stripe_id" TO "id";
--
-- Rename field stripe_id on source to id
--
ALTER TABLE "djstripe_source" RENAME COLUMN "stripe_id" TO "id";
--
-- Rename field stripe_id on subscription to id
--
ALTER TABLE "djstripe_subscription" RENAME COLUMN "stripe_id" TO "id";
--
-- Rename field stripe_id on transfer to id
--
ALTER TABLE "djstripe_transfer" RENAME COLUMN "stripe_id" TO "id";
--
-- Rename field stripe_id on coupon to id
--
ALTER TABLE "djstripe_coupon" RENAME COLUMN "stripe_id" TO "id";
--
-- Alter field percent_off on coupon
--
ALTER TABLE "djstripe_coupon" DROP CONSTRAINT "djstripe_coupon_percent_off_73bc98c0_check";
ALTER TABLE "djstripe_coupon" ALTER COLUMN "percent_off" TYPE numeric(5, 2) USING "percent_off"::numeric(5, 2);
--
-- Alter field business_name on account
--
ALTER TABLE "djstripe_account" ALTER COLUMN "business_name" SET DEFAULT '';
UPDATE "djstripe_account" SET "business_name" = '' WHERE "business_name" IS NULL;
ALTER TABLE "djstripe_account" ALTER COLUMN "business_name" SET NOT NULL;
ALTER TABLE "djstripe_account" ALTER COLUMN "business_name" DROP DEFAULT;
--
-- Alter field business_primary_color on account
--
ALTER TABLE "djstripe_account" ALTER COLUMN "business_primary_color" SET DEFAULT '';
UPDATE "djstripe_account" SET "business_primary_color" = '' WHERE "business_primary_color" IS NULL;
ALTER TABLE "djstripe_account" ALTER COLUMN "business_primary_color" SET NOT NULL;
ALTER TABLE "djstripe_account" ALTER COLUMN "business_primary_color" DROP DEFAULT;
--
-- Alter field business_url on account
--
ALTER TABLE "djstripe_account" ALTER COLUMN "business_url" SET DEFAULT '';
UPDATE "djstripe_account" SET "business_url" = '' WHERE "business_url" IS NULL;
ALTER TABLE "djstripe_account" ALTER COLUMN "business_url" SET NOT NULL;
ALTER TABLE "djstripe_account" ALTER COLUMN "business_url" DROP DEFAULT;
--
-- Alter field payout_statement_descriptor on account
--
UPDATE "djstripe_account" SET "payout_statement_descriptor" = '' WHERE "payout_statement_descriptor" IS NULL;
ALTER TABLE "djstripe_account" ALTER COLUMN "payout_statement_descriptor" SET NOT NULL;
--
-- Alter field product_description on account
--
ALTER TABLE "djstripe_account" ALTER COLUMN "product_description" SET DEFAULT '';
UPDATE "djstripe_account" SET "product_description" = '' WHERE "product_description" IS NULL;
ALTER TABLE "djstripe_account" ALTER COLUMN "product_description" SET NOT NULL;
ALTER TABLE "djstripe_account" ALTER COLUMN "product_description" DROP DEFAULT;
--
-- Alter field support_url on account
--
ALTER TABLE "djstripe_account" ALTER COLUMN "support_url" SET DEFAULT '';
UPDATE "djstripe_account" SET "support_url" = '' WHERE "support_url" IS NULL;
ALTER TABLE "djstripe_account" ALTER COLUMN "support_url" SET NOT NULL;
ALTER TABLE "djstripe_account" ALTER COLUMN "support_url" DROP DEFAULT;
--
-- Alter field account_holder_name on bankaccount
--
ALTER TABLE "djstripe_bankaccount" ALTER COLUMN "account_holder_name" TYPE text USING "account_holder_name"::text, ALTER COLUMN "account_holder_name" SET DEFAULT '';
UPDATE "djstripe_bankaccount" SET "account_holder_name" = '' WHERE "account_holder_name" IS NULL;
ALTER TABLE "djstripe_bankaccount" ALTER COLUMN "account_holder_name" SET NOT NULL;
ALTER TABLE "djstripe_bankaccount" ALTER COLUMN "account_holder_name" DROP DEFAULT;
--
-- Alter field address_city on card
--
ALTER TABLE "djstripe_card" ALTER COLUMN "address_city" SET DEFAULT '';
UPDATE "djstripe_card" SET "address_city" = '' WHERE "address_city" IS NULL;
ALTER TABLE "djstripe_card" ALTER COLUMN "address_city" SET NOT NULL;
ALTER TABLE "djstripe_card" ALTER COLUMN "address_city" DROP DEFAULT;
--
-- Alter field address_country on card
--
ALTER TABLE "djstripe_card" ALTER COLUMN "address_country" SET DEFAULT '';
UPDATE "djstripe_card" SET "address_country" = '' WHERE "address_country" IS NULL;
ALTER TABLE "djstripe_card" ALTER COLUMN "address_country" SET NOT NULL;
ALTER TABLE "djstripe_card" ALTER COLUMN "address_country" DROP DEFAULT;
--
-- Alter field address_line1 on card
--
ALTER TABLE "djstripe_card" ALTER COLUMN "address_line1" SET DEFAULT '';
UPDATE "djstripe_card" SET "address_line1" = '' WHERE "address_line1" IS NULL;
ALTER TABLE "djstripe_card" ALTER COLUMN "address_line1" SET NOT NULL;
ALTER TABLE "djstripe_card" ALTER COLUMN "address_line1" DROP DEFAULT;
--
-- Alter field address_line1_check on card
--
ALTER TABLE "djstripe_card" ALTER COLUMN "address_line1_check" SET DEFAULT '';
UPDATE "djstripe_card" SET "address_line1_check" = '' WHERE "address_line1_check" IS NULL;
ALTER TABLE "djstripe_card" ALTER COLUMN "address_line1_check" SET NOT NULL;
ALTER TABLE "djstripe_card" ALTER COLUMN "address_line1_check" DROP DEFAULT;
--
-- Alter field address_line2 on card
--
ALTER TABLE "djstripe_card" ALTER COLUMN "address_line2" SET DEFAULT '';
UPDATE "djstripe_card" SET "address_line2" = '' WHERE "address_line2" IS NULL;
ALTER TABLE "djstripe_card" ALTER COLUMN "address_line2" SET NOT NULL;
ALTER TABLE "djstripe_card" ALTER COLUMN "address_line2" DROP DEFAULT;
--
-- Alter field address_state on card
--
ALTER TABLE "djstripe_card" ALTER COLUMN "address_state" SET DEFAULT '';
UPDATE "djstripe_card" SET "address_state" = '' WHERE "address_state" IS NULL;
ALTER TABLE "djstripe_card" ALTER COLUMN "address_state" SET NOT NULL;
ALTER TABLE "djstripe_card" ALTER COLUMN "address_state" DROP DEFAULT;
--
-- Alter field address_zip on card
--
ALTER TABLE "djstripe_card" ALTER COLUMN "address_zip" SET DEFAULT '';
UPDATE "djstripe_card" SET "address_zip" = '' WHERE "address_zip" IS NULL;
ALTER TABLE "djstripe_card" ALTER COLUMN "address_zip" SET NOT NULL;
ALTER TABLE "djstripe_card" ALTER COLUMN "address_zip" DROP DEFAULT;
--
-- Alter field address_zip_check on card
--
ALTER TABLE "djstripe_card" ALTER COLUMN "address_zip_check" SET DEFAULT '';
UPDATE "djstripe_card" SET "address_zip_check" = '' WHERE "address_zip_check" IS NULL;
ALTER TABLE "djstripe_card" ALTER COLUMN "address_zip_check" SET NOT NULL;
ALTER TABLE "djstripe_card" ALTER COLUMN "address_zip_check" DROP DEFAULT;
--
-- Alter field country on card
--
ALTER TABLE "djstripe_card" ALTER COLUMN "country" SET DEFAULT '';
UPDATE "djstripe_card" SET "country" = '' WHERE "country" IS NULL;
ALTER TABLE "djstripe_card" ALTER COLUMN "country" SET NOT NULL;
ALTER TABLE "djstripe_card" ALTER COLUMN "country" DROP DEFAULT;
--
-- Alter field cvc_check on card
--
ALTER TABLE "djstripe_card" ALTER COLUMN "cvc_check" SET DEFAULT '';
UPDATE "djstripe_card" SET "cvc_check" = '' WHERE "cvc_check" IS NULL;
ALTER TABLE "djstripe_card" ALTER COLUMN "cvc_check" SET NOT NULL;
ALTER TABLE "djstripe_card" ALTER COLUMN "cvc_check" DROP DEFAULT;
--
-- Alter field dynamic_last4 on card
--
ALTER TABLE "djstripe_card" ALTER COLUMN "dynamic_last4" SET DEFAULT '';
UPDATE "djstripe_card" SET "dynamic_last4" = '' WHERE "dynamic_last4" IS NULL;
ALTER TABLE "djstripe_card" ALTER COLUMN "dynamic_last4" SET NOT NULL;
ALTER TABLE "djstripe_card" ALTER COLUMN "dynamic_last4" DROP DEFAULT;
--
-- Alter field fingerprint on card
--
ALTER TABLE "djstripe_card" ALTER COLUMN "fingerprint" TYPE varchar(16) USING "fingerprint"::varchar(16), ALTER COLUMN "fingerprint" SET DEFAULT '';
UPDATE "djstripe_card" SET "fingerprint" = '' WHERE "fingerprint" IS NULL;
ALTER TABLE "djstripe_card" ALTER COLUMN "fingerprint" SET NOT NULL;
ALTER TABLE "djstripe_card" ALTER COLUMN "fingerprint" DROP DEFAULT;
--
-- Alter field name on card
--
ALTER TABLE "djstripe_card" ALTER COLUMN "name" SET DEFAULT '';
UPDATE "djstripe_card" SET "name" = '' WHERE "name" IS NULL;
ALTER TABLE "djstripe_card" ALTER COLUMN "name" SET NOT NULL;
ALTER TABLE "djstripe_card" ALTER COLUMN "name" DROP DEFAULT;
--
-- Alter field tokenization_method on card
--
ALTER TABLE "djstripe_card" ALTER COLUMN "tokenization_method" SET DEFAULT '';
UPDATE "djstripe_card" SET "tokenization_method" = '' WHERE "tokenization_method" IS NULL;
ALTER TABLE "djstripe_card" ALTER COLUMN "tokenization_method" SET NOT NULL;
ALTER TABLE "djstripe_card" ALTER COLUMN "tokenization_method" DROP DEFAULT;
--
-- Alter field failure_code on charge
--
ALTER TABLE "djstripe_charge" ALTER COLUMN "failure_code" TYPE varchar(42) USING "failure_code"::varchar(42), ALTER COLUMN "failure_code" SET DEFAULT '';
UPDATE "djstripe_charge" SET "failure_code" = '' WHERE "failure_code" IS NULL;
ALTER TABLE "djstripe_charge" ALTER COLUMN "failure_code" SET NOT NULL;
ALTER TABLE "djstripe_charge" ALTER COLUMN "failure_code" DROP DEFAULT;
--
-- Alter field failure_message on charge
--
ALTER TABLE "djstripe_charge" ALTER COLUMN "failure_message" SET DEFAULT '';
UPDATE "djstripe_charge" SET "failure_message" = '' WHERE "failure_message" IS NULL;
ALTER TABLE "djstripe_charge" ALTER COLUMN "failure_message" SET NOT NULL;
ALTER TABLE "djstripe_charge" ALTER COLUMN "failure_message" DROP DEFAULT;
--
-- Alter field receipt_email on charge
--
ALTER TABLE "djstripe_charge" ALTER COLUMN "receipt_email" TYPE text USING "receipt_email"::text, ALTER COLUMN "receipt_email" SET DEFAULT '';
UPDATE "djstripe_charge" SET "receipt_email" = '' WHERE "receipt_email" IS NULL;
ALTER TABLE "djstripe_charge" ALTER COLUMN "receipt_email" SET NOT NULL;
ALTER TABLE "djstripe_charge" ALTER COLUMN "receipt_email" DROP DEFAULT;
--
-- Alter field receipt_number on charge
--
ALTER TABLE "djstripe_charge" ALTER COLUMN "receipt_number" SET DEFAULT '';
UPDATE "djstripe_charge" SET "receipt_number" = '' WHERE "receipt_number" IS NULL;
ALTER TABLE "djstripe_charge" ALTER COLUMN "receipt_number" SET NOT NULL;
ALTER TABLE "djstripe_charge" ALTER COLUMN "receipt_number" DROP DEFAULT;
--
-- Alter field statement_descriptor on charge
--
ALTER TABLE "djstripe_charge" ALTER COLUMN "statement_descriptor" SET DEFAULT '';
UPDATE "djstripe_charge" SET "statement_descriptor" = '' WHERE "statement_descriptor" IS NULL;
ALTER TABLE "djstripe_charge" ALTER COLUMN "statement_descriptor" SET NOT NULL;
ALTER TABLE "djstripe_charge" ALTER COLUMN "statement_descriptor" DROP DEFAULT;
--
-- Alter field transfer_group on charge
--
ALTER TABLE "djstripe_charge" ALTER COLUMN "transfer_group" SET DEFAULT '';
UPDATE "djstripe_charge" SET "transfer_group" = '' WHERE "transfer_group" IS NULL;
ALTER TABLE "djstripe_charge" ALTER COLUMN "transfer_group" SET NOT NULL;
ALTER TABLE "djstripe_charge" ALTER COLUMN "transfer_group" DROP DEFAULT;
--
-- Alter field business_vat_id on customer
--
ALTER TABLE "djstripe_customer" ALTER COLUMN "business_vat_id" SET DEFAULT '';
UPDATE "djstripe_customer" SET "business_vat_id" = '' WHERE "business_vat_id" IS NULL;
ALTER TABLE "djstripe_customer" ALTER COLUMN "business_vat_id" SET NOT NULL;
ALTER TABLE "djstripe_customer" ALTER COLUMN "business_vat_id" DROP DEFAULT;
--
-- Alter field currency on customer
--
ALTER TABLE "djstripe_customer" ALTER COLUMN "currency" SET DEFAULT '';
UPDATE "djstripe_customer" SET "currency" = '' WHERE "currency" IS NULL;
ALTER TABLE "djstripe_customer" ALTER COLUMN "currency" SET NOT NULL;
ALTER TABLE "djstripe_customer" ALTER COLUMN "currency" DROP DEFAULT;
--
-- Alter field email on customer
--
ALTER TABLE "djstripe_customer" ALTER COLUMN "email" SET DEFAULT '';
UPDATE "djstripe_customer" SET "email" = '' WHERE "email" IS NULL;
ALTER TABLE "djstripe_customer" ALTER COLUMN "email" SET NOT NULL;
ALTER TABLE "djstripe_customer" ALTER COLUMN "email" DROP DEFAULT;
--
-- Alter field idempotency_key on event
--
ALTER TABLE "djstripe_event" ALTER COLUMN "idempotency_key" SET DEFAULT '';
UPDATE "djstripe_event" SET "idempotency_key" = '' WHERE "idempotency_key" IS NULL;
ALTER TABLE "djstripe_event" ALTER COLUMN "idempotency_key" SET NOT NULL;
ALTER TABLE "djstripe_event" ALTER COLUMN "idempotency_key" DROP DEFAULT;
--
-- Alter field request_id on event
--
ALTER TABLE "djstripe_event" ALTER COLUMN "request_id" SET DEFAULT '';
UPDATE "djstripe_event" SET "request_id" = '' WHERE "request_id" IS NULL;
ALTER TABLE "djstripe_event" ALTER COLUMN "request_id" SET NOT NULL;
ALTER TABLE "djstripe_event" ALTER COLUMN "request_id" DROP DEFAULT;
--
-- Alter field hosted_invoice_url on invoice
--
ALTER TABLE "djstripe_invoice" ALTER COLUMN "hosted_invoice_url" TYPE text USING "hosted_invoice_url"::text, ALTER COLUMN "hosted_invoice_url" SET DEFAULT '';
UPDATE "djstripe_invoice" SET "hosted_invoice_url" = '' WHERE "hosted_invoice_url" IS NULL;
ALTER TABLE "djstripe_invoice" ALTER COLUMN "hosted_invoice_url" SET NOT NULL;
ALTER TABLE "djstripe_invoice" ALTER COLUMN "hosted_invoice_url" DROP DEFAULT;
--
-- Alter field invoice_pdf on invoice
--
ALTER TABLE "djstripe_invoice" ALTER COLUMN "invoice_pdf" TYPE text USING "invoice_pdf"::text, ALTER COLUMN "invoice_pdf" SET DEFAULT '';
UPDATE "djstripe_invoice" SET "invoice_pdf" = '' WHERE "invoice_pdf" IS NULL;
ALTER TABLE "djstripe_invoice" ALTER COLUMN "invoice_pdf" SET NOT NULL;
ALTER TABLE "djstripe_invoice" ALTER COLUMN "invoice_pdf" DROP DEFAULT;
--
-- Alter field number on invoice
--
ALTER TABLE "djstripe_invoice" ALTER COLUMN "number" SET DEFAULT '';
UPDATE "djstripe_invoice" SET "number" = '' WHERE "number" IS NULL;
ALTER TABLE "djstripe_invoice" ALTER COLUMN "number" SET NOT NULL;
ALTER TABLE "djstripe_invoice" ALTER COLUMN "number" DROP DEFAULT;
--
-- Alter field statement_descriptor on invoice
--
ALTER TABLE "djstripe_invoice" ALTER COLUMN "statement_descriptor" SET DEFAULT '';
UPDATE "djstripe_invoice" SET "statement_descriptor" = '' WHERE "statement_descriptor" IS NULL;
ALTER TABLE "djstripe_invoice" ALTER COLUMN "statement_descriptor" SET NOT NULL;
ALTER TABLE "djstripe_invoice" ALTER COLUMN "statement_descriptor" DROP DEFAULT;
--
-- Alter field failure_code on payout
--
ALTER TABLE "djstripe_payout" ALTER COLUMN "failure_code" SET DEFAULT '';
UPDATE "djstripe_payout" SET "failure_code" = '' WHERE "failure_code" IS NULL;
ALTER TABLE "djstripe_payout" ALTER COLUMN "failure_code" SET NOT NULL;
ALTER TABLE "djstripe_payout" ALTER COLUMN "failure_code" DROP DEFAULT;
--
-- Alter field failure_message on payout
--
ALTER TABLE "djstripe_payout" ALTER COLUMN "failure_message" SET DEFAULT '';
UPDATE "djstripe_payout" SET "failure_message" = '' WHERE "failure_message" IS NULL;
ALTER TABLE "djstripe_payout" ALTER COLUMN "failure_message" SET NOT NULL;
ALTER TABLE "djstripe_payout" ALTER COLUMN "failure_message" DROP DEFAULT;
--
-- Alter field statement_descriptor on payout
--
ALTER TABLE "djstripe_payout" ALTER COLUMN "statement_descriptor" SET DEFAULT '';
UPDATE "djstripe_payout" SET "statement_descriptor" = '' WHERE "statement_descriptor" IS NULL;
ALTER TABLE "djstripe_payout" ALTER COLUMN "statement_descriptor" SET NOT NULL;
ALTER TABLE "djstripe_payout" ALTER COLUMN "statement_descriptor" DROP DEFAULT;
--
-- Alter field aggregate_usage on plan
--
ALTER TABLE "djstripe_plan" ALTER COLUMN "aggregate_usage" SET DEFAULT '';
UPDATE "djstripe_plan" SET "aggregate_usage" = '' WHERE "aggregate_usage" IS NULL;
ALTER TABLE "djstripe_plan" ALTER COLUMN "aggregate_usage" SET NOT NULL;
ALTER TABLE "djstripe_plan" ALTER COLUMN "aggregate_usage" DROP DEFAULT;
--
-- Alter field billing_scheme on plan
--
ALTER TABLE "djstripe_plan" ALTER COLUMN "billing_scheme" SET DEFAULT '';
UPDATE "djstripe_plan" SET "billing_scheme" = '' WHERE "billing_scheme" IS NULL;
ALTER TABLE "djstripe_plan" ALTER COLUMN "billing_scheme" SET NOT NULL;
ALTER TABLE "djstripe_plan" ALTER COLUMN "billing_scheme" DROP DEFAULT;
--
-- Alter field nickname on plan
--
ALTER TABLE "djstripe_plan" ALTER COLUMN "nickname" TYPE text USING "nickname"::text, ALTER COLUMN "nickname" SET DEFAULT '';
UPDATE "djstripe_plan" SET "nickname" = '' WHERE "nickname" IS NULL;
ALTER TABLE "djstripe_plan" ALTER COLUMN "nickname" SET NOT NULL;
ALTER TABLE "djstripe_plan" ALTER COLUMN "nickname" DROP DEFAULT;
--
-- Alter field caption on product
--
ALTER TABLE "djstripe_product" ALTER COLUMN "caption" TYPE text USING "caption"::text, ALTER COLUMN "caption" SET DEFAULT '';
UPDATE "djstripe_product" SET "caption" = '' WHERE "caption" IS NULL;
ALTER TABLE "djstripe_product" ALTER COLUMN "caption" SET NOT NULL;
ALTER TABLE "djstripe_product" ALTER COLUMN "caption" DROP DEFAULT;
--
-- Alter field statement_descriptor on product
--
ALTER TABLE "djstripe_product" ALTER COLUMN "statement_descriptor" SET DEFAULT '';
UPDATE "djstripe_product" SET "statement_descriptor" = '' WHERE "statement_descriptor" IS NULL;
ALTER TABLE "djstripe_product" ALTER COLUMN "statement_descriptor" SET NOT NULL;
ALTER TABLE "djstripe_product" ALTER COLUMN "statement_descriptor" DROP DEFAULT;
--
-- Alter field unit_label on product
--
ALTER TABLE "djstripe_product" ALTER COLUMN "unit_label" SET DEFAULT '';
UPDATE "djstripe_product" SET "unit_label" = '' WHERE "unit_label" IS NULL;
ALTER TABLE "djstripe_product" ALTER COLUMN "unit_label" SET NOT NULL;
ALTER TABLE "djstripe_product" ALTER COLUMN "unit_label" DROP DEFAULT;
--
-- Alter field failure_reason on refund
--
ALTER TABLE "djstripe_refund" ALTER COLUMN "failure_reason" SET DEFAULT '';
UPDATE "djstripe_refund" SET "failure_reason" = '' WHERE "failure_reason" IS NULL;
ALTER TABLE "djstripe_refund" ALTER COLUMN "failure_reason" SET NOT NULL;
ALTER TABLE "djstripe_refund" ALTER COLUMN "failure_reason" DROP DEFAULT;
--
-- Alter field reason on refund
--
ALTER TABLE "djstripe_refund" ALTER COLUMN "reason" SET DEFAULT '';
UPDATE "djstripe_refund" SET "reason" = '' WHERE "reason" IS NULL;
ALTER TABLE "djstripe_refund" ALTER COLUMN "reason" SET NOT NULL;
ALTER TABLE "djstripe_refund" ALTER COLUMN "reason" DROP DEFAULT;
--
-- Alter field receipt_number on refund
--
ALTER TABLE "djstripe_refund" ALTER COLUMN "receipt_number" SET DEFAULT '';
UPDATE "djstripe_refund" SET "receipt_number" = '' WHERE "receipt_number" IS NULL;
ALTER TABLE "djstripe_refund" ALTER COLUMN "receipt_number" SET NOT NULL;
ALTER TABLE "djstripe_refund" ALTER COLUMN "receipt_number" DROP DEFAULT;
--
-- Alter field currency on source
--
ALTER TABLE "djstripe_source" ALTER COLUMN "currency" SET DEFAULT '';
UPDATE "djstripe_source" SET "currency" = '' WHERE "currency" IS NULL;
ALTER TABLE "djstripe_source" ALTER COLUMN "currency" SET NOT NULL;
ALTER TABLE "djstripe_source" ALTER COLUMN "currency" DROP DEFAULT;
--
-- Alter field statement_descriptor on source
--
ALTER TABLE "djstripe_source" ALTER COLUMN "statement_descriptor" SET DEFAULT '';
UPDATE "djstripe_source" SET "statement_descriptor" = '' WHERE "statement_descriptor" IS NULL;
ALTER TABLE "djstripe_source" ALTER COLUMN "statement_descriptor" SET NOT NULL;
ALTER TABLE "djstripe_source" ALTER COLUMN "statement_descriptor" DROP DEFAULT;
--
-- Alter field transfer_group on transfer
--
ALTER TABLE "djstripe_transfer" ALTER COLUMN "transfer_group" SET DEFAULT '';
UPDATE "djstripe_transfer" SET "transfer_group" = '' WHERE "transfer_group" IS NULL;
ALTER TABLE "djstripe_transfer" ALTER COLUMN "transfer_group" SET NOT NULL;
ALTER TABLE "djstripe_transfer" ALTER COLUMN "transfer_group" DROP DEFAULT;
--
-- Alter field name on product
--
ALTER TABLE "djstripe_product" ALTER COLUMN "name" TYPE text USING "name"::text;
--
-- Alter field plan on subscription
--
SET CONSTRAINTS "djstripe_subscriptio_plan_id_9129d5d5_fk_djstripe_" IMMEDIATE; ALTER TABLE "djstripe_subscription" DROP CONSTRAINT "djstripe_subscriptio_plan_id_9129d5d5_fk_djstripe_";
ALTER TABLE "djstripe_subscription" ALTER COLUMN "plan_id" DROP NOT NULL;
ALTER TABLE "djstripe_subscription" ADD CONSTRAINT "djstripe_subscriptio_plan_id_9129d5d5_fk_djstripe_" FOREIGN KEY ("plan_id") REFERENCES "djstripe_plan" ("djstripe_id") DEFERRABLE INITIALLY DEFERRED;
--
-- Alter field quantity on subscription
--
ALTER TABLE "djstripe_subscription" ALTER COLUMN "quantity" DROP NOT NULL;
--
-- Alter field amount on plan
--
ALTER TABLE "djstripe_plan" ALTER COLUMN "amount" DROP NOT NULL;
--
-- Alter field closed on invoice
--
ALTER TABLE "djstripe_invoice" ALTER COLUMN "closed" DROP NOT NULL;
--
-- Alter field forgiven on invoice
--
ALTER TABLE "djstripe_invoice" ALTER COLUMN "forgiven" DROP NOT NULL;
--
-- Rename model PaymentMethod to DjstripePaymentMethod
--
ALTER TABLE "djstripe_paymentmethod" RENAME TO "djstripe_djstripepaymentmethod";
SET CONSTRAINTS "djstripe_customer_default_source_id_24020f62_fk_djstripe_" IMMEDIATE; ALTER TABLE "djstripe_customer" DROP CONSTRAINT "djstripe_customer_default_source_id_24020f62_fk_djstripe_";
ALTER TABLE "djstripe_customer" ADD CONSTRAINT "djstripe_customer_default_source_id_24020f62_fk_djstripe_" FOREIGN KEY ("default_source_id") REFERENCES "djstripe_djstripepaymentmethod" ("id") DEFERRABLE INITIALLY DEFERRED;
SET CONSTRAINTS "djstripe_charge_source_id_2502db60_fk_djstripe_paymentmethod_id" IMMEDIATE; ALTER TABLE "djstripe_charge" DROP CONSTRAINT "djstripe_charge_source_id_2502db60_fk_djstripe_paymentmethod_id";
ALTER TABLE "djstripe_charge" ADD CONSTRAINT "djstripe_charge_source_id_2502db60_fk_djstripe_" FOREIGN KEY ("source_id") REFERENCES "djstripe_djstripepaymentmethod" ("id") DEFERRABLE INITIALLY DEFERRED;
CREATE INDEX "djstripe_countryspec_id_f0eac598_like" ON "djstripe_countryspec" ("id" varchar_pattern_ops);
CREATE INDEX "djstripe_balancetransaction_id_178c6a1f_like" ON "djstripe_balancetransaction" ("id" varchar_pattern_ops);
ALTER TABLE "djstripe_scheduledqueryrun" ADD CONSTRAINT "djstripe_scheduledqu_file_id_707bbc03_fk_djstripe_" FOREIGN KEY ("file_id") REFERENCES "djstripe_fileupload" ("djstripe_id") DEFERRABLE INITIALLY DEFERRED;
CREATE INDEX "djstripe_scheduledqueryrun_id_94f43855_like" ON "djstripe_scheduledqueryrun" ("id" varchar_pattern_ops);
CREATE INDEX "djstripe_scheduledqueryrun_file_id_707bbc03" ON "djstripe_scheduledqueryrun" ("file_id");
ALTER TABLE "djstripe_subscriptionitem" ADD CONSTRAINT "djstripe_subscriptio_plan_id_cc68cb43_fk_djstripe_" FOREIGN KEY ("plan_id") REFERENCES "djstripe_plan" ("djstripe_id") DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE "djstripe_subscriptionitem" ADD CONSTRAINT "djstripe_subscriptio_subscription_id_992d9919_fk_djstripe_" FOREIGN KEY ("subscription_id") REFERENCES "djstripe_subscription" ("djstripe_id") DEFERRABLE INITIALLY DEFERRED;
CREATE INDEX "djstripe_subscriptionitem_id_6f0d84b1_like" ON "djstripe_subscriptionitem" ("id" varchar_pattern_ops);
CREATE INDEX "djstripe_subscriptionitem_plan_id_cc68cb43" ON "djstripe_subscriptionitem" ("plan_id");
CREATE INDEX "djstripe_subscriptionitem_subscription_id_992d9919" ON "djstripe_subscriptionitem" ("subscription_id");
ALTER TABLE "djstripe_transferreversal" ADD CONSTRAINT "djstripe_transferrev_balance_transaction__5044f084_fk_djstripe_" FOREIGN KEY ("balance_transaction_id") REFERENCES "djstripe_balancetransaction" ("djstripe_id") DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE "djstripe_transferreversal" ADD CONSTRAINT "djstripe_transferrev_transfer_id_8f250dd3_fk_djstripe_" FOREIGN KEY ("transfer_id") REFERENCES "djstripe_transfer" ("djstripe_id") DEFERRABLE INITIALLY DEFERRED;
CREATE INDEX "djstripe_transferreversal_id_229d4d84_like" ON "djstripe_transferreversal" ("id" varchar_pattern_ops);
CREATE INDEX "djstripe_transferreversal_balance_transaction_id_5044f084" ON "djstripe_transferreversal" ("balance_transaction_id");
CREATE INDEX "djstripe_transferreversal_transfer_id_8f250dd3" ON "djstripe_transferreversal" ("transfer_id");
ALTER TABLE "djstripe_usagerecord" ADD CONSTRAINT "djstripe_usagerecord_subscription_item_id_5a38e1e2_fk_djstripe_" FOREIGN KEY ("subscription_item_id") REFERENCES "djstripe_subscriptionitem" ("djstripe_id") DEFERRABLE INITIALLY DEFERRED;
CREATE INDEX "djstripe_usagerecord_id_61b9b1fd_like" ON "djstripe_usagerecord" ("id" varchar_pattern_ops);
CREATE INDEX "djstripe_usagerecord_subscription_item_id_5a38e1e2" ON "djstripe_usagerecord" ("subscription_item_id");
ALTER TABLE "djstripe_applicationfee" ADD CONSTRAINT "djstripe_application_balance_transaction__ff735754_fk_djstripe_" FOREIGN KEY ("balance_transaction_id") REFERENCES "djstripe_balancetransaction" ("djstripe_id") DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE "djstripe_applicationfee" ADD CONSTRAINT "djstripe_application_charge_id_8ba8ce37_fk_djstripe_" FOREIGN KEY ("charge_id") REFERENCES "djstripe_charge" ("djstripe_id") DEFERRABLE INITIALLY DEFERRED;
CREATE INDEX "djstripe_applicationfee_id_0e5dcda7_like" ON "djstripe_applicationfee" ("id" varchar_pattern_ops);
CREATE INDEX "djstripe_applicationfee_balance_transaction_id_ff735754" ON "djstripe_applicationfee" ("balance_transaction_id");
CREATE INDEX "djstripe_applicationfee_charge_id_8ba8ce37" ON "djstripe_applicationfee" ("charge_id");
ALTER TABLE "djstripe_applicationfeerefund" ADD CONSTRAINT "djstripe_application_balance_transaction__bc35b031_fk_djstripe_" FOREIGN KEY ("balance_transaction_id") REFERENCES "djstripe_balancetransaction" ("djstripe_id") DEFERRABLE INITIALLY DEFERRED;
ALTER TABLE "djstripe_applicationfeerefund" ADD CONSTRAINT "djstripe_application_fee_id_8fabef2d_fk_djstripe_" FOREIGN KEY ("fee_id") REFERENCES "djstripe_applicationfee" ("djstripe_id") DEFERRABLE INITIALLY DEFERRED;
CREATE INDEX "djstripe_applicationfeerefund_id_4b8013c7_like" ON "djstripe_applicationfeerefund" ("id" varchar_pattern_ops);
CREATE INDEX "djstripe_applicationfeerefund_balance_transaction_id_bc35b031" ON "djstripe_applicationfeerefund" ("balance_transaction_id");
CREATE INDEX "djstripe_applicationfeerefund_fee_id_8fabef2d" ON "djstripe_applicationfeerefund" ("fee_id");
CREATE INDEX "djstripe_charge_balance_transaction_id_2eac625e" ON "djstripe_charge" ("balance_transaction_id");
ALTER TABLE "djstripe_charge" ADD CONSTRAINT "djstripe_charge_balance_transaction__2eac625e_fk_djstripe_" FOREIGN KEY ("balance_transaction_id") REFERENCES "djstripe_balancetransaction" ("djstripe_id") DEFERRABLE INITIALLY DEFERRED;
CREATE INDEX "djstripe_payout_balance_transaction_id_a9393fb6" ON "djstripe_payout" ("balance_transaction_id");
ALTER TABLE "djstripe_payout" ADD CONSTRAINT "djstripe_payout_balance_transaction__a9393fb6_fk_djstripe_" FOREIGN KEY ("balance_transaction_id") REFERENCES "djstripe_balancetransaction" ("djstripe_id") DEFERRABLE INITIALLY DEFERRED;
CREATE INDEX "djstripe_payout_failure_balance_transaction_id_77d442db" ON "djstripe_payout" ("failure_balance_transaction_id");
ALTER TABLE "djstripe_payout" ADD CONSTRAINT "djstripe_payout_failure_balance_tran_77d442db_fk_djstripe_" FOREIGN KEY ("failure_balance_transaction_id") REFERENCES "djstripe_balancetransaction" ("djstripe_id") DEFERRABLE INITIALLY DEFERRED;
CREATE INDEX "djstripe_refund_balance_transaction_id_dec480cf" ON "djstripe_refund" ("balance_transaction_id");
ALTER TABLE "djstripe_refund" ADD CONSTRAINT "djstripe_refund_balance_transaction__dec480cf_fk_djstripe_" FOREIGN KEY ("balance_transaction_id") REFERENCES "djstripe_balancetransaction" ("djstripe_id") DEFERRABLE INITIALLY DEFERRED;
CREATE INDEX "djstripe_refund_failure_balance_transaction_id_817ae640" ON "djstripe_refund" ("failure_balance_transaction_id");
ALTER TABLE "djstripe_refund" ADD CONSTRAINT "djstripe_refund_failure_balance_tran_817ae640_fk_djstripe_" FOREIGN KEY ("failure_balance_transaction_id") REFERENCES "djstripe_balancetransaction" ("djstripe_id") DEFERRABLE INITIALLY DEFERRED;
CREATE INDEX "djstripe_transfer_balance_transaction_id_b5b00270" ON "djstripe_transfer" ("balance_transaction_id");
ALTER TABLE "djstripe_transfer" ADD CONSTRAINT "djstripe_transfer_balance_transaction__b5b00270_fk_djstripe_" FOREIGN KEY ("balance_transaction_id") REFERENCES "djstripe_balancetransaction" ("djstripe_id") DEFERRABLE INITIALLY DEFERRED;
COMMIT;
@therefromhere
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment