Skip to content

Commit 6ce2b9c

Browse files
authored
feat: implement viewing and managing of recurring payments (#82)
1 parent 52539a5 commit 6ce2b9c

40 files changed

+3014
-147
lines changed

drizzle.config.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
1-
import { type Config } from "drizzle-kit";
1+
import type { Config } from "drizzle-kit";
22

33
export default {
4-
schema: "./src/server/db/schema.ts",
5-
dialect: "postgresql",
6-
dbCredentials: {
7-
url: process.env.DATABASE_URL as string,
8-
},
9-
tablesFilter: ["easyinvoice_*"],
4+
schema: "./src/server/db/schema.ts",
5+
dialect: "postgresql",
6+
dbCredentials: {
7+
url:
8+
process.env.DATABASE_URL ??
9+
(() => {
10+
throw new Error("DATABASE_URL is not set");
11+
})(),
12+
},
13+
tablesFilter: ["easyinvoice_*"],
1014
} satisfies Config;

drizzle/0006_open_owl.sql

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
CREATE TYPE "public"."frequency_enum" AS ENUM('DAILY', 'WEEKLY', 'MONTHLY', 'YEARLY');--> statement-breakpoint
2+
CREATE TYPE "public"."recurring_payment_status" AS ENUM('pending', 'active', 'paused', 'completed', 'cancelled');--> statement-breakpoint
3+
CREATE TABLE IF NOT EXISTS "easyinvoice_recurring_payment" (
4+
"id" text PRIMARY KEY NOT NULL,
5+
"externalPaymentId" text NOT NULL,
6+
"status" "recurring_payment_status" DEFAULT 'pending' NOT NULL,
7+
"totalAmount" text NOT NULL,
8+
"paymentCurrency" text NOT NULL,
9+
"chain" text NOT NULL,
10+
"totalNumberOfPayments" integer,
11+
"currentNumberOfPayments" integer DEFAULT 0,
12+
"created_at" timestamp DEFAULT now(),
13+
"userId" text NOT NULL,
14+
"recurrence" json NOT NULL,
15+
"recipient" json NOT NULL,
16+
"payments" json
17+
);
18+
--> statement-breakpoint
19+
DO $$ BEGIN
20+
ALTER TABLE "easyinvoice_recurring_payment" ADD CONSTRAINT "easyinvoice_recurring_payment_userId_easyinvoice_user_id_fk" FOREIGN KEY ("userId") REFERENCES "public"."easyinvoice_user"("id") ON DELETE cascade ON UPDATE no action;
21+
EXCEPTION
22+
WHEN duplicate_object THEN null;
23+
END $$;

0 commit comments

Comments
 (0)