Skip to content

Commit

Permalink
refactor: planetscale -> neon
Browse files Browse the repository at this point in the history
  • Loading branch information
sadmann7 committed Mar 8, 2024
1 parent 0f15f93 commit dbc9ed3
Show file tree
Hide file tree
Showing 25 changed files with 586 additions and 1,514 deletions.
4 changes: 2 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
# Use the production URL when deploying to production
NEXT_PUBLIC_APP_URL="http://localhost:3000"

# Get the Database URL from the "prisma" dropdown selector in PlanetScale. Change the query params at the end of the URL to "?ssl={"rejectUnauthorized":true}"
DATABASE_URL="mysql://YOUR_MYSQL_URL_HERE?ssl={"rejectUnauthorized":true}"
# Database
DATABASE_URL="mysql://YOUR_POSTGRESSQL_URL_HERE"

# Clerk Auth
# pk_test, and sk_test are development keys
Expand Down
35 changes: 21 additions & 14 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
{
"tailwindCSS.includeLanguages": {
"plaintext": "html"
},
"tailwindCSS.experimental.classRegex": [
["cva\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"],
["cn\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"],
["tw=\"([^\"]*)\""]
],
"markdownlint.config": {
"MD033": {
"allowed_elements": ["img", "p", "a"]
},
"MD045": false
}
"tailwindCSS.includeLanguages": {
"plaintext": "html"
},
"tailwindCSS.experimental.classRegex": [
["cva\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"],
["cn\\(([^)]*)\\)", "[\"'`]([^\"'`]*).*?[\"'`]"],
["tw=\"([^\"]*)\""]
],
"markdownlint.config": {
"MD033": {
"allowed_elements": ["img", "p", "a"]
},
"MD045": false
},
"json.schemas": [
{
"fileMatch": ["/package.json"],
"url": "https://json.schemastore.org/package",
"schema": true
}
]
}
8 changes: 4 additions & 4 deletions drizzle.config.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { env } from "@/env.js"
import type { Config } from "drizzle-kit"
import { type Config } from "drizzle-kit"

import { databasePrefix } from "@/lib/constants"

export default {
schema: "./src/db/schema.ts",
driver: "mysql2",
driver: "pg",
out: "./drizzle",
dbCredentials: {
uri: env.DATABASE_URL,
connectionString: env.DATABASE_URL,
},
// tablesFilter: [`${databasePrefix}_*`],
tablesFilter: [`${databasePrefix}_*`],
} satisfies Config
112 changes: 112 additions & 0 deletions drizzle/0000_next_gambit.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
DO $$ BEGIN
CREATE TYPE "skateshop_category" AS ENUM('skateboards', 'clothing', 'shoes', 'accessories');
EXCEPTION
WHEN duplicate_object THEN null;
END $$;
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "skateshop_addresses" (
"id" varchar(30) PRIMARY KEY NOT NULL,
"line1" varchar(256),
"line2" varchar(256),
"city" varchar(256),
"state" varchar(256),
"postal_code" varchar(256),
"country" varchar(256),
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT current_timestamp
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "skateshop_carts" (
"id" varchar(30) PRIMARY KEY NOT NULL,
"payment_intent_id" varchar(256),
"client_secret" varchar(256),
"items" json DEFAULT 'null'::json,
"closed" boolean DEFAULT false NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT current_timestamp
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "skateshop_notifications" (
"id" varchar(30) PRIMARY KEY NOT NULL,
"user_id" varchar(36),
"email" varchar(256) NOT NULL,
"token" varchar(256) NOT NULL,
"referred_by" varchar(256),
"newsletter" boolean DEFAULT false NOT NULL,
"marketing" boolean DEFAULT false NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT current_timestamp,
CONSTRAINT "skateshop_notifications_user_id_unique" UNIQUE("user_id"),
CONSTRAINT "skateshop_notifications_email_unique" UNIQUE("email"),
CONSTRAINT "skateshop_notifications_token_unique" UNIQUE("token")
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "skateshop_orders" (
"id" varchar(30) PRIMARY KEY NOT NULL,
"store_id" varchar(30) NOT NULL,
"items" json DEFAULT 'null'::json,
"quantity" integer,
"amount" numeric(10, 2) DEFAULT '0' NOT NULL,
"stripe_payment_intent_id" varchar(256) NOT NULL,
"stripe_payment_intent_status" varchar(256) NOT NULL,
"name" varchar(256) NOT NULL,
"email" varchar(256) NOT NULL,
"address_id" integer,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT current_timestamp
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "skateshop_payments" (
"id" varchar(30) PRIMARY KEY NOT NULL,
"store_id" varchar(30) NOT NULL,
"stripe_account_id" varchar(256) NOT NULL,
"stripe_account_created_at" integer,
"stripe_account_expires_at" integer,
"details_submitted" boolean DEFAULT false NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT current_timestamp
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "skateshop_products" (
"id" varchar(30) PRIMARY KEY NOT NULL,
"name" varchar(256) NOT NULL,
"description" text,
"images" json DEFAULT 'null'::json,
"category" "skateshop_category" DEFAULT 'skateboards' NOT NULL,
"subcategory" varchar(256),
"price" numeric(10, 2) DEFAULT '0' NOT NULL,
"inventory" integer DEFAULT 0 NOT NULL,
"rating" integer DEFAULT 0 NOT NULL,
"tags" json DEFAULT 'null'::json,
"store_id" varchar(30) NOT NULL,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT current_timestamp
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "skateshop_stores" (
"id" varchar(30) PRIMARY KEY NOT NULL,
"user_id" varchar(36),
"name" varchar NOT NULL,
"description" text,
"slug" text,
"active" boolean DEFAULT false NOT NULL,
"stripe_account_id" varchar,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT current_timestamp,
CONSTRAINT "skateshop_stores_user_id_unique" UNIQUE("user_id"),
CONSTRAINT "skateshop_stores_slug_unique" UNIQUE("slug")
);
--> statement-breakpoint
CREATE TABLE IF NOT EXISTS "skateshop_subscriptions" (
"id" varchar(30) PRIMARY KEY NOT NULL,
"user_id" varchar(36),
"stripe_subscription_id" varchar(256),
"stripe_price_id" varchar(256),
"stripe_customer_id" varchar(256),
"stripe_current_period_end" timestamp,
"created_at" timestamp DEFAULT now() NOT NULL,
"updated_at" timestamp DEFAULT current_timestamp,
CONSTRAINT "skateshop_subscriptions_user_id_unique" UNIQUE("user_id")
);
--> statement-breakpoint
CREATE INDEX IF NOT EXISTS "store_id_idx" ON "skateshop_products" ("store_id");
112 changes: 0 additions & 112 deletions drizzle/0000_thick_the_watchers.sql

This file was deleted.

8 changes: 0 additions & 8 deletions drizzle/0001_noisy_kronos.sql

This file was deleted.

Loading

0 comments on commit dbc9ed3

Please sign in to comment.