You've already forked AstralRinth
forked from didirus/AstralRinth
Add revenue split to affiliate codes v2 (#4672)
* wip: affiliate payouts again * Implement affiliate payout queue * Deactivate subscription affiliations on cancellation * Remove a test that never compiled in the first place * Update sqlx cache * address some PR comments * more comments * wip: handle refund charges * cargo sqlx prepare * Address PR comments * cargo sqlx prepare
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
CREATE TABLE users_subscriptions_affiliations (
|
||||
subscription_id BIGINT NOT NULL REFERENCES users_subscriptions(id),
|
||||
affiliate_code BIGINT NOT NULL REFERENCES affiliate_codes(id),
|
||||
created_at TIMESTAMPTZ NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
deactivated_at TIMESTAMPTZ,
|
||||
UNIQUE (subscription_id)
|
||||
);
|
||||
|
||||
CREATE TABLE users_subscriptions_affiliations_payouts(
|
||||
id BIGSERIAL PRIMARY KEY,
|
||||
charge_id BIGINT NOT NULL REFERENCES charges(id),
|
||||
subscription_id BIGINT NOT NULL REFERENCES users_subscriptions(id),
|
||||
affiliate_code BIGINT NOT NULL REFERENCES affiliate_codes(id),
|
||||
payout_value_id BIGSERIAL NOT NULL REFERENCES payouts_values(id),
|
||||
UNIQUE (charge_id),
|
||||
UNIQUE (payout_value_id)
|
||||
);
|
||||
|
||||
ALTER TABLE payouts_values
|
||||
ADD COLUMN affiliate_code_source BIGINT;
|
||||
Reference in New Issue
Block a user