stripe-experiment-sync 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +100 -0
- package/dist/index.cjs +2370 -0
- package/dist/index.d.cts +222 -0
- package/dist/index.d.ts +222 -0
- package/dist/index.js +2328 -0
- package/dist/migrations/0000_initial_migration.sql +1 -0
- package/dist/migrations/0001_products.sql +17 -0
- package/dist/migrations/0002_customers.sql +23 -0
- package/dist/migrations/0003_prices.sql +34 -0
- package/dist/migrations/0004_subscriptions.sql +56 -0
- package/dist/migrations/0005_invoices.sql +77 -0
- package/dist/migrations/0006_charges.sql +43 -0
- package/dist/migrations/0007_coupons.sql +19 -0
- package/dist/migrations/0008_disputes.sql +17 -0
- package/dist/migrations/0009_events.sql +12 -0
- package/dist/migrations/0010_payouts.sql +30 -0
- package/dist/migrations/0011_plans.sql +25 -0
- package/dist/migrations/0012_add_updated_at.sql +108 -0
- package/dist/migrations/0013_add_subscription_items.sql +12 -0
- package/dist/migrations/0014_migrate_subscription_items.sql +26 -0
- package/dist/migrations/0015_add_customer_deleted.sql +2 -0
- package/dist/migrations/0016_add_invoice_indexes.sql +2 -0
- package/dist/migrations/0017_drop_charges_unavailable_columns.sql +6 -0
- package/dist/migrations/0018_setup_intents.sql +17 -0
- package/dist/migrations/0019_payment_methods.sql +12 -0
- package/dist/migrations/0020_disputes_payment_intent_created_idx.sql +3 -0
- package/dist/migrations/0021_payment_intent.sql +42 -0
- package/dist/migrations/0022_adjust_plans.sql +5 -0
- package/dist/migrations/0023_invoice_deleted.sql +1 -0
- package/dist/migrations/0024_subscription_schedules.sql +29 -0
- package/dist/migrations/0025_tax_ids.sql +14 -0
- package/dist/migrations/0026_credit_notes.sql +36 -0
- package/dist/migrations/0027_add_marketing_features_to_products.sql +2 -0
- package/dist/migrations/0028_early_fraud_warning.sql +22 -0
- package/dist/migrations/0029_reviews.sql +28 -0
- package/dist/migrations/0030_refunds.sql +29 -0
- package/dist/migrations/0031_add_default_price.sql +2 -0
- package/dist/migrations/0032_update_subscription_items.sql +3 -0
- package/dist/migrations/0033_add_last_synced_at.sql +85 -0
- package/dist/migrations/0034_remove_foreign_keys.sql +13 -0
- package/dist/migrations/0035_checkout_sessions.sql +77 -0
- package/dist/migrations/0036_checkout_session_line_items.sql +24 -0
- package/dist/migrations/0037_add_features.sql +18 -0
- package/dist/migrations/0038_active_entitlement.sql +20 -0
- package/dist/migrations/0039_add_paused_to_subscription_status.sql +1 -0
- package/dist/migrations/0040_managed_webhooks.sql +28 -0
- package/package.json +60 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
select 1;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
create table if not exists "stripe"."products" (
|
|
2
|
+
"id" text primary key,
|
|
3
|
+
"object" text,
|
|
4
|
+
"active" boolean,
|
|
5
|
+
"description" text,
|
|
6
|
+
"metadata" jsonb,
|
|
7
|
+
"name" text,
|
|
8
|
+
"created" integer,
|
|
9
|
+
"images" jsonb,
|
|
10
|
+
"livemode" boolean,
|
|
11
|
+
"package_dimensions" jsonb,
|
|
12
|
+
"shippable" boolean,
|
|
13
|
+
"statement_descriptor" text,
|
|
14
|
+
"unit_label" text,
|
|
15
|
+
"updated" integer,
|
|
16
|
+
"url" text
|
|
17
|
+
);
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
create table if not exists "stripe"."customers" (
|
|
2
|
+
"id" text primary key,
|
|
3
|
+
"object" text,
|
|
4
|
+
"address" jsonb,
|
|
5
|
+
"description" text,
|
|
6
|
+
"email" text,
|
|
7
|
+
"metadata" jsonb,
|
|
8
|
+
"name" text,
|
|
9
|
+
"phone" text,
|
|
10
|
+
"shipping" jsonb,
|
|
11
|
+
"balance" integer,
|
|
12
|
+
"created" integer,
|
|
13
|
+
"currency" text,
|
|
14
|
+
"default_source" text,
|
|
15
|
+
"delinquent" boolean,
|
|
16
|
+
"discount" jsonb,
|
|
17
|
+
"invoice_prefix" text,
|
|
18
|
+
"invoice_settings" jsonb,
|
|
19
|
+
"livemode" boolean,
|
|
20
|
+
"next_invoice_sequence" integer,
|
|
21
|
+
"preferred_locales" jsonb,
|
|
22
|
+
"tax_exempt" text
|
|
23
|
+
);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
DO $$
|
|
2
|
+
BEGIN
|
|
3
|
+
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'pricing_type') THEN
|
|
4
|
+
create type "stripe"."pricing_type" as enum ('one_time', 'recurring');
|
|
5
|
+
END IF;
|
|
6
|
+
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'pricing_tiers') THEN
|
|
7
|
+
create type "stripe"."pricing_tiers" as enum ('graduated', 'volume');
|
|
8
|
+
END IF;
|
|
9
|
+
--more types here...
|
|
10
|
+
END
|
|
11
|
+
$$;
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
create table if not exists "stripe"."prices" (
|
|
15
|
+
"id" text primary key,
|
|
16
|
+
"object" text,
|
|
17
|
+
"active" boolean,
|
|
18
|
+
"currency" text,
|
|
19
|
+
"metadata" jsonb,
|
|
20
|
+
"nickname" text,
|
|
21
|
+
"recurring" jsonb,
|
|
22
|
+
"type" stripe.pricing_type,
|
|
23
|
+
"unit_amount" integer,
|
|
24
|
+
"billing_scheme" text,
|
|
25
|
+
"created" integer,
|
|
26
|
+
"livemode" boolean,
|
|
27
|
+
"lookup_key" text,
|
|
28
|
+
"tiers_mode" stripe.pricing_tiers,
|
|
29
|
+
"transform_quantity" jsonb,
|
|
30
|
+
"unit_amount_decimal" text,
|
|
31
|
+
|
|
32
|
+
"product" text references stripe.products
|
|
33
|
+
);
|
|
34
|
+
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
|
|
2
|
+
DO $$
|
|
3
|
+
BEGIN
|
|
4
|
+
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'subscription_status') THEN
|
|
5
|
+
create type "stripe"."subscription_status" as enum (
|
|
6
|
+
'trialing',
|
|
7
|
+
'active',
|
|
8
|
+
'canceled',
|
|
9
|
+
'incomplete',
|
|
10
|
+
'incomplete_expired',
|
|
11
|
+
'past_due',
|
|
12
|
+
'unpaid'
|
|
13
|
+
);
|
|
14
|
+
END IF;
|
|
15
|
+
END
|
|
16
|
+
$$;
|
|
17
|
+
|
|
18
|
+
create table if not exists "stripe"."subscriptions" (
|
|
19
|
+
"id" text primary key,
|
|
20
|
+
"object" text,
|
|
21
|
+
"cancel_at_period_end" boolean,
|
|
22
|
+
"current_period_end" integer,
|
|
23
|
+
"current_period_start" integer,
|
|
24
|
+
"default_payment_method" text,
|
|
25
|
+
"items" jsonb,
|
|
26
|
+
"metadata" jsonb,
|
|
27
|
+
"pending_setup_intent" text,
|
|
28
|
+
"pending_update" jsonb,
|
|
29
|
+
"status" "stripe"."subscription_status",
|
|
30
|
+
"application_fee_percent" double precision,
|
|
31
|
+
"billing_cycle_anchor" integer,
|
|
32
|
+
"billing_thresholds" jsonb,
|
|
33
|
+
"cancel_at" integer,
|
|
34
|
+
"canceled_at" integer,
|
|
35
|
+
"collection_method" text,
|
|
36
|
+
"created" integer,
|
|
37
|
+
"days_until_due" integer,
|
|
38
|
+
"default_source" text,
|
|
39
|
+
"default_tax_rates" jsonb,
|
|
40
|
+
"discount" jsonb,
|
|
41
|
+
"ended_at" integer,
|
|
42
|
+
"livemode" boolean,
|
|
43
|
+
"next_pending_invoice_item_invoice" integer,
|
|
44
|
+
"pause_collection" jsonb,
|
|
45
|
+
"pending_invoice_item_interval" jsonb,
|
|
46
|
+
"start_date" integer,
|
|
47
|
+
"transfer_data" jsonb,
|
|
48
|
+
"trial_end" jsonb,
|
|
49
|
+
"trial_start" jsonb,
|
|
50
|
+
|
|
51
|
+
"schedule" text,
|
|
52
|
+
"customer" text references "stripe"."customers",
|
|
53
|
+
"latest_invoice" text, -- not yet joined
|
|
54
|
+
"plan" text -- not yet joined
|
|
55
|
+
);
|
|
56
|
+
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
|
|
2
|
+
DO $$
|
|
3
|
+
BEGIN
|
|
4
|
+
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'invoice_status') THEN
|
|
5
|
+
create type "stripe"."invoice_status" as enum ('draft', 'open', 'paid', 'uncollectible', 'void');
|
|
6
|
+
END IF;
|
|
7
|
+
END
|
|
8
|
+
$$;
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
create table if not exists "stripe"."invoices" (
|
|
12
|
+
"id" text primary key,
|
|
13
|
+
"object" text,
|
|
14
|
+
"auto_advance" boolean,
|
|
15
|
+
"collection_method" text,
|
|
16
|
+
"currency" text,
|
|
17
|
+
"description" text,
|
|
18
|
+
"hosted_invoice_url" text,
|
|
19
|
+
"lines" jsonb,
|
|
20
|
+
"metadata" jsonb,
|
|
21
|
+
"period_end" integer,
|
|
22
|
+
"period_start" integer,
|
|
23
|
+
"status" "stripe"."invoice_status",
|
|
24
|
+
"total" bigint,
|
|
25
|
+
"account_country" text,
|
|
26
|
+
"account_name" text,
|
|
27
|
+
"account_tax_ids" jsonb,
|
|
28
|
+
"amount_due" bigint,
|
|
29
|
+
"amount_paid" bigint,
|
|
30
|
+
"amount_remaining" bigint,
|
|
31
|
+
"application_fee_amount" bigint,
|
|
32
|
+
"attempt_count" integer,
|
|
33
|
+
"attempted" boolean,
|
|
34
|
+
"billing_reason" text,
|
|
35
|
+
"created" integer,
|
|
36
|
+
"custom_fields" jsonb,
|
|
37
|
+
"customer_address" jsonb,
|
|
38
|
+
"customer_email" text,
|
|
39
|
+
"customer_name" text,
|
|
40
|
+
"customer_phone" text,
|
|
41
|
+
"customer_shipping" jsonb,
|
|
42
|
+
"customer_tax_exempt" text,
|
|
43
|
+
"customer_tax_ids" jsonb,
|
|
44
|
+
"default_tax_rates" jsonb,
|
|
45
|
+
"discount" jsonb,
|
|
46
|
+
"discounts" jsonb,
|
|
47
|
+
"due_date" integer,
|
|
48
|
+
"ending_balance" integer,
|
|
49
|
+
"footer" text,
|
|
50
|
+
"invoice_pdf" text,
|
|
51
|
+
"last_finalization_error" jsonb,
|
|
52
|
+
"livemode" boolean,
|
|
53
|
+
"next_payment_attempt" integer,
|
|
54
|
+
"number" text,
|
|
55
|
+
"paid" boolean,
|
|
56
|
+
"payment_settings" jsonb,
|
|
57
|
+
"post_payment_credit_notes_amount" integer,
|
|
58
|
+
"pre_payment_credit_notes_amount" integer,
|
|
59
|
+
"receipt_number" text,
|
|
60
|
+
"starting_balance" integer,
|
|
61
|
+
"statement_descriptor" text,
|
|
62
|
+
"status_transitions" jsonb,
|
|
63
|
+
"subtotal" integer,
|
|
64
|
+
"tax" integer,
|
|
65
|
+
"total_discount_amounts" jsonb,
|
|
66
|
+
"total_tax_amounts" jsonb,
|
|
67
|
+
"transfer_data" jsonb,
|
|
68
|
+
"webhooks_delivered_at" integer,
|
|
69
|
+
|
|
70
|
+
"customer" text references "stripe"."customers",
|
|
71
|
+
"subscription" text references "stripe"."subscriptions",
|
|
72
|
+
"payment_intent" text, -- not yet implemented
|
|
73
|
+
"default_payment_method" text, -- not yet implemented
|
|
74
|
+
"default_source" text, -- not yet implemented
|
|
75
|
+
"on_behalf_of" text, -- not yet implemented
|
|
76
|
+
"charge" text -- not yet implemented
|
|
77
|
+
);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
|
|
2
|
+
create table if not exists "stripe".charges (
|
|
3
|
+
id text primary key,
|
|
4
|
+
object text,
|
|
5
|
+
card jsonb,
|
|
6
|
+
paid boolean,
|
|
7
|
+
"order" text,
|
|
8
|
+
amount bigint,
|
|
9
|
+
review text,
|
|
10
|
+
source jsonb,
|
|
11
|
+
status text,
|
|
12
|
+
created integer,
|
|
13
|
+
dispute text,
|
|
14
|
+
invoice text,
|
|
15
|
+
outcome jsonb,
|
|
16
|
+
refunds jsonb,
|
|
17
|
+
updated integer,
|
|
18
|
+
captured boolean,
|
|
19
|
+
currency text,
|
|
20
|
+
customer text,
|
|
21
|
+
livemode boolean,
|
|
22
|
+
metadata jsonb,
|
|
23
|
+
refunded boolean,
|
|
24
|
+
shipping jsonb,
|
|
25
|
+
application text,
|
|
26
|
+
description text,
|
|
27
|
+
destination text,
|
|
28
|
+
failure_code text,
|
|
29
|
+
on_behalf_of text,
|
|
30
|
+
fraud_details jsonb,
|
|
31
|
+
receipt_email text,
|
|
32
|
+
payment_intent text,
|
|
33
|
+
receipt_number text,
|
|
34
|
+
transfer_group text,
|
|
35
|
+
amount_refunded bigint,
|
|
36
|
+
application_fee text,
|
|
37
|
+
failure_message text,
|
|
38
|
+
source_transfer text,
|
|
39
|
+
balance_transaction text,
|
|
40
|
+
statement_descriptor text,
|
|
41
|
+
statement_description text,
|
|
42
|
+
payment_method_details jsonb
|
|
43
|
+
);
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
create table if not exists "stripe".coupons (
|
|
2
|
+
id text primary key,
|
|
3
|
+
object text,
|
|
4
|
+
name text,
|
|
5
|
+
valid boolean,
|
|
6
|
+
created integer,
|
|
7
|
+
updated integer,
|
|
8
|
+
currency text,
|
|
9
|
+
duration text,
|
|
10
|
+
livemode boolean,
|
|
11
|
+
metadata jsonb,
|
|
12
|
+
redeem_by integer,
|
|
13
|
+
amount_off bigint,
|
|
14
|
+
percent_off double precision,
|
|
15
|
+
times_redeemed bigint,
|
|
16
|
+
max_redemptions bigint,
|
|
17
|
+
duration_in_months bigint,
|
|
18
|
+
percent_off_precise double precision
|
|
19
|
+
);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
create table if not exists "stripe".disputes (
|
|
2
|
+
id text primary key,
|
|
3
|
+
object text,
|
|
4
|
+
amount bigint,
|
|
5
|
+
charge text,
|
|
6
|
+
reason text,
|
|
7
|
+
status text,
|
|
8
|
+
created integer,
|
|
9
|
+
updated integer,
|
|
10
|
+
currency text,
|
|
11
|
+
evidence jsonb,
|
|
12
|
+
livemode boolean,
|
|
13
|
+
metadata jsonb,
|
|
14
|
+
evidence_details jsonb,
|
|
15
|
+
balance_transactions jsonb,
|
|
16
|
+
is_charge_refundable boolean
|
|
17
|
+
);
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
create table if not exists "stripe".payouts (
|
|
2
|
+
id text primary key,
|
|
3
|
+
object text,
|
|
4
|
+
date text,
|
|
5
|
+
type text,
|
|
6
|
+
amount bigint,
|
|
7
|
+
method text,
|
|
8
|
+
status text,
|
|
9
|
+
created integer,
|
|
10
|
+
updated integer,
|
|
11
|
+
currency text,
|
|
12
|
+
livemode boolean,
|
|
13
|
+
metadata jsonb,
|
|
14
|
+
automatic boolean,
|
|
15
|
+
recipient text,
|
|
16
|
+
description text,
|
|
17
|
+
destination text,
|
|
18
|
+
source_type text,
|
|
19
|
+
arrival_date text,
|
|
20
|
+
bank_account jsonb,
|
|
21
|
+
failure_code text,
|
|
22
|
+
transfer_group text,
|
|
23
|
+
amount_reversed bigint,
|
|
24
|
+
failure_message text,
|
|
25
|
+
source_transaction text,
|
|
26
|
+
balance_transaction text,
|
|
27
|
+
statement_descriptor text,
|
|
28
|
+
statement_description text,
|
|
29
|
+
failure_balance_transaction text
|
|
30
|
+
);
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
create table if not exists "stripe"."plans" (
|
|
2
|
+
id text primary key,
|
|
3
|
+
object text,
|
|
4
|
+
name text,
|
|
5
|
+
tiers jsonb,
|
|
6
|
+
active boolean,
|
|
7
|
+
amount bigint,
|
|
8
|
+
created integer,
|
|
9
|
+
product text,
|
|
10
|
+
updated integer,
|
|
11
|
+
currency text,
|
|
12
|
+
"interval" text,
|
|
13
|
+
livemode boolean,
|
|
14
|
+
metadata jsonb,
|
|
15
|
+
nickname text,
|
|
16
|
+
tiers_mode text,
|
|
17
|
+
usage_type text,
|
|
18
|
+
billing_scheme text,
|
|
19
|
+
interval_count bigint,
|
|
20
|
+
aggregate_usage text,
|
|
21
|
+
transform_usage text,
|
|
22
|
+
trial_period_days bigint,
|
|
23
|
+
statement_descriptor text,
|
|
24
|
+
statement_description text
|
|
25
|
+
);
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
create or replace function set_updated_at() returns trigger
|
|
2
|
+
language plpgsql
|
|
3
|
+
as
|
|
4
|
+
$$
|
|
5
|
+
begin
|
|
6
|
+
new.updated_at = now();
|
|
7
|
+
return NEW;
|
|
8
|
+
end;
|
|
9
|
+
$$;
|
|
10
|
+
|
|
11
|
+
alter table stripe.subscriptions
|
|
12
|
+
add updated_at timestamptz default timezone('utc'::text, now()) not null;
|
|
13
|
+
|
|
14
|
+
create trigger handle_updated_at
|
|
15
|
+
before update
|
|
16
|
+
on stripe.subscriptions
|
|
17
|
+
for each row
|
|
18
|
+
execute procedure set_updated_at();
|
|
19
|
+
|
|
20
|
+
alter table stripe.products
|
|
21
|
+
add updated_at timestamptz default timezone('utc'::text, now()) not null;
|
|
22
|
+
|
|
23
|
+
create trigger handle_updated_at
|
|
24
|
+
before update
|
|
25
|
+
on stripe.products
|
|
26
|
+
for each row
|
|
27
|
+
execute procedure set_updated_at();
|
|
28
|
+
|
|
29
|
+
alter table stripe.customers
|
|
30
|
+
add updated_at timestamptz default timezone('utc'::text, now()) not null;
|
|
31
|
+
|
|
32
|
+
create trigger handle_updated_at
|
|
33
|
+
before update
|
|
34
|
+
on stripe.customers
|
|
35
|
+
for each row
|
|
36
|
+
execute procedure set_updated_at();
|
|
37
|
+
|
|
38
|
+
alter table stripe.prices
|
|
39
|
+
add updated_at timestamptz default timezone('utc'::text, now()) not null;
|
|
40
|
+
|
|
41
|
+
create trigger handle_updated_at
|
|
42
|
+
before update
|
|
43
|
+
on stripe.prices
|
|
44
|
+
for each row
|
|
45
|
+
execute procedure set_updated_at();
|
|
46
|
+
|
|
47
|
+
alter table stripe.invoices
|
|
48
|
+
add updated_at timestamptz default timezone('utc'::text, now()) not null;
|
|
49
|
+
|
|
50
|
+
create trigger handle_updated_at
|
|
51
|
+
before update
|
|
52
|
+
on stripe.invoices
|
|
53
|
+
for each row
|
|
54
|
+
execute procedure set_updated_at();
|
|
55
|
+
|
|
56
|
+
alter table stripe.charges
|
|
57
|
+
add updated_at timestamptz default timezone('utc'::text, now()) not null;
|
|
58
|
+
|
|
59
|
+
create trigger handle_updated_at
|
|
60
|
+
before update
|
|
61
|
+
on stripe.charges
|
|
62
|
+
for each row
|
|
63
|
+
execute procedure set_updated_at();
|
|
64
|
+
|
|
65
|
+
alter table stripe.coupons
|
|
66
|
+
add updated_at timestamptz default timezone('utc'::text, now()) not null;
|
|
67
|
+
|
|
68
|
+
create trigger handle_updated_at
|
|
69
|
+
before update
|
|
70
|
+
on stripe.coupons
|
|
71
|
+
for each row
|
|
72
|
+
execute procedure set_updated_at();
|
|
73
|
+
|
|
74
|
+
alter table stripe.disputes
|
|
75
|
+
add updated_at timestamptz default timezone('utc'::text, now()) not null;
|
|
76
|
+
|
|
77
|
+
create trigger handle_updated_at
|
|
78
|
+
before update
|
|
79
|
+
on stripe.disputes
|
|
80
|
+
for each row
|
|
81
|
+
execute procedure set_updated_at();
|
|
82
|
+
|
|
83
|
+
alter table stripe.events
|
|
84
|
+
add updated_at timestamptz default timezone('utc'::text, now()) not null;
|
|
85
|
+
|
|
86
|
+
create trigger handle_updated_at
|
|
87
|
+
before update
|
|
88
|
+
on stripe.events
|
|
89
|
+
for each row
|
|
90
|
+
execute procedure set_updated_at();
|
|
91
|
+
|
|
92
|
+
alter table stripe.payouts
|
|
93
|
+
add updated_at timestamptz default timezone('utc'::text, now()) not null;
|
|
94
|
+
|
|
95
|
+
create trigger handle_updated_at
|
|
96
|
+
before update
|
|
97
|
+
on stripe.payouts
|
|
98
|
+
for each row
|
|
99
|
+
execute procedure set_updated_at();
|
|
100
|
+
|
|
101
|
+
alter table stripe.plans
|
|
102
|
+
add updated_at timestamptz default timezone('utc'::text, now()) not null;
|
|
103
|
+
|
|
104
|
+
create trigger handle_updated_at
|
|
105
|
+
before update
|
|
106
|
+
on stripe.plans
|
|
107
|
+
for each row
|
|
108
|
+
execute procedure set_updated_at();
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
create table if not exists "stripe"."subscription_items" (
|
|
2
|
+
"id" text primary key,
|
|
3
|
+
"object" text,
|
|
4
|
+
"billing_thresholds" jsonb,
|
|
5
|
+
"created" integer,
|
|
6
|
+
"deleted" boolean,
|
|
7
|
+
"metadata" jsonb,
|
|
8
|
+
"quantity" integer,
|
|
9
|
+
"price" text references "stripe"."prices",
|
|
10
|
+
"subscription" text references "stripe"."subscriptions",
|
|
11
|
+
"tax_rates" jsonb
|
|
12
|
+
);
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
WITH subscriptions AS (
|
|
2
|
+
select jsonb_array_elements(items->'data') as obj from "stripe"."subscriptions"
|
|
3
|
+
)
|
|
4
|
+
insert into "stripe"."subscription_items"
|
|
5
|
+
select obj->>'id' as "id",
|
|
6
|
+
obj->>'object' as "object",
|
|
7
|
+
obj->'billing_thresholds' as "billing_thresholds",
|
|
8
|
+
(obj->>'created')::INTEGER as "created",
|
|
9
|
+
(obj->>'deleted')::BOOLEAN as "deleted",
|
|
10
|
+
obj->'metadata' as "metadata",
|
|
11
|
+
(obj->>'quantity')::INTEGER as "quantity",
|
|
12
|
+
(obj->'price'->>'id')::TEXT as "price",
|
|
13
|
+
obj->>'subscription' as "subscription",
|
|
14
|
+
obj->'tax_rates' as "tax_rates"
|
|
15
|
+
from subscriptions
|
|
16
|
+
on conflict ("id")
|
|
17
|
+
do update set "id" = excluded."id",
|
|
18
|
+
"object" = excluded."object",
|
|
19
|
+
"billing_thresholds" = excluded."billing_thresholds",
|
|
20
|
+
"created" = excluded."created",
|
|
21
|
+
"deleted" = excluded."deleted",
|
|
22
|
+
"metadata" = excluded."metadata",
|
|
23
|
+
"quantity" = excluded."quantity",
|
|
24
|
+
"price" = excluded."price",
|
|
25
|
+
"subscription" = excluded."subscription",
|
|
26
|
+
"tax_rates" = excluded."tax_rates"
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
-- drop columns that are duplicated / not available anymore
|
|
2
|
+
-- card is not available on webhook v.2020-03-02. We can get the detail from payment_method_details
|
|
3
|
+
-- statement_description is not available on webhook v.2020-03-02
|
|
4
|
+
alter table "stripe"."charges"
|
|
5
|
+
drop column if exists "card",
|
|
6
|
+
drop column if exists "statement_description";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
create table if not exists "stripe"."setup_intents" (
|
|
2
|
+
id text primary key,
|
|
3
|
+
object text,
|
|
4
|
+
created integer,
|
|
5
|
+
customer text,
|
|
6
|
+
description text,
|
|
7
|
+
payment_method text,
|
|
8
|
+
status text,
|
|
9
|
+
usage text,
|
|
10
|
+
cancellation_reason text,
|
|
11
|
+
latest_attempt text,
|
|
12
|
+
mandate text,
|
|
13
|
+
single_use_mandate text,
|
|
14
|
+
on_behalf_of text
|
|
15
|
+
);
|
|
16
|
+
|
|
17
|
+
CREATE INDEX stripe_setup_intents_customer_idx ON "stripe"."setup_intents" USING btree (customer);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
create table if not exists "stripe"."payment_methods" (
|
|
2
|
+
id text primary key,
|
|
3
|
+
object text,
|
|
4
|
+
created integer,
|
|
5
|
+
customer text,
|
|
6
|
+
type text,
|
|
7
|
+
billing_details jsonb,
|
|
8
|
+
metadata jsonb,
|
|
9
|
+
card jsonb
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
CREATE INDEX stripe_payment_methods_customer_idx ON "stripe"."payment_methods" USING btree (customer);
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
create table if not exists "stripe"."payment_intents" (
|
|
2
|
+
id text primary key,
|
|
3
|
+
object text,
|
|
4
|
+
amount integer,
|
|
5
|
+
amount_capturable integer,
|
|
6
|
+
amount_details jsonb,
|
|
7
|
+
amount_received integer,
|
|
8
|
+
application text,
|
|
9
|
+
application_fee_amount integer,
|
|
10
|
+
automatic_payment_methods text,
|
|
11
|
+
canceled_at integer,
|
|
12
|
+
cancellation_reason text,
|
|
13
|
+
capture_method text,
|
|
14
|
+
client_secret text,
|
|
15
|
+
confirmation_method text,
|
|
16
|
+
created integer,
|
|
17
|
+
currency text,
|
|
18
|
+
customer text,
|
|
19
|
+
description text,
|
|
20
|
+
invoice text,
|
|
21
|
+
last_payment_error text,
|
|
22
|
+
livemode boolean,
|
|
23
|
+
metadata jsonb,
|
|
24
|
+
next_action text,
|
|
25
|
+
on_behalf_of text,
|
|
26
|
+
payment_method text,
|
|
27
|
+
payment_method_options jsonb,
|
|
28
|
+
payment_method_types jsonb,
|
|
29
|
+
processing text,
|
|
30
|
+
receipt_email text,
|
|
31
|
+
review text,
|
|
32
|
+
setup_future_usage text,
|
|
33
|
+
shipping jsonb,
|
|
34
|
+
statement_descriptor text,
|
|
35
|
+
statement_descriptor_suffix text,
|
|
36
|
+
status text,
|
|
37
|
+
transfer_data jsonb,
|
|
38
|
+
transfer_group text
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
CREATE INDEX stripe_payment_intents_customer_idx ON "stripe"."payment_intents" USING btree (customer);
|
|
42
|
+
CREATE INDEX stripe_payment_intents_invoice_idx ON "stripe"."payment_intents" USING btree (invoice);
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
ALTER TABLE if exists "stripe"."plans" DROP COLUMN name;
|
|
2
|
+
ALTER TABLE if exists "stripe"."plans" DROP COLUMN updated;
|
|
3
|
+
ALTER TABLE if exists "stripe"."plans" DROP COLUMN tiers;
|
|
4
|
+
ALTER TABLE if exists "stripe"."plans" DROP COLUMN statement_descriptor;
|
|
5
|
+
ALTER TABLE if exists "stripe"."plans" DROP COLUMN statement_description;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ALTER TYPE "stripe"."invoice_status" ADD VALUE 'deleted';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
do $$
|
|
2
|
+
BEGIN
|
|
3
|
+
IF NOT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'subscription_schedule_status') THEN
|
|
4
|
+
create type "stripe"."subscription_schedule_status" as enum ('not_started', 'active', 'completed', 'released', 'canceled');
|
|
5
|
+
END IF;
|
|
6
|
+
END
|
|
7
|
+
$$;
|
|
8
|
+
|
|
9
|
+
create table if not exists
|
|
10
|
+
"stripe"."subscription_schedules" (
|
|
11
|
+
id text primary key,
|
|
12
|
+
object text,
|
|
13
|
+
application text,
|
|
14
|
+
canceled_at integer,
|
|
15
|
+
completed_at integer,
|
|
16
|
+
created integer not null,
|
|
17
|
+
current_phase jsonb,
|
|
18
|
+
customer text not null,
|
|
19
|
+
default_settings jsonb,
|
|
20
|
+
end_behavior text,
|
|
21
|
+
livemode boolean not null,
|
|
22
|
+
metadata jsonb not null,
|
|
23
|
+
phases jsonb not null,
|
|
24
|
+
released_at integer,
|
|
25
|
+
released_subscription text,
|
|
26
|
+
status stripe.subscription_schedule_status not null,
|
|
27
|
+
subscription text,
|
|
28
|
+
test_clock text
|
|
29
|
+
);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
create table if not exists
|
|
2
|
+
"stripe"."tax_ids" (
|
|
3
|
+
"id" text primary key,
|
|
4
|
+
"object" text,
|
|
5
|
+
"country" text,
|
|
6
|
+
"customer" text,
|
|
7
|
+
"type" text,
|
|
8
|
+
"value" text,
|
|
9
|
+
"created" integer not null,
|
|
10
|
+
"livemode" boolean,
|
|
11
|
+
"owner" jsonb
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
create index stripe_tax_ids_customer_idx on "stripe"."tax_ids" using btree (customer);
|