Moved to Fly Postgres

This commit is contained in:
Atridad Lahiji 2024-01-06 00:37:58 -07:00
parent c3093b95b1
commit f286fcac34
No known key found for this signature in database
9 changed files with 603 additions and 4457 deletions

View file

@ -1,6 +1,5 @@
#Database
DATABASE_URL=""
DATABASE_AUTH_TOKEN=""
REDIS_URL=""
#Auth

View file

@ -27,7 +27,7 @@ export async function action({ request, params, context }: ActionFunctionArgs) {
roomName: data.name,
storyName: "First Story!",
scale: "0.5,1,2,3,5,8",
visible: 0,
visible: false,
})
.returning();

View file

@ -45,8 +45,8 @@ export async function loader({ context, params, request }: LoaderFunctionArgs) {
presenceData.map((presenceItem) => {
return {
...presenceItem,
isAdmin: presenceItem.isAdmin === 0 ? false : true,
isVIP: presenceItem.isVIP === 0 ? false : true,
isAdmin: presenceItem.isAdmin,
isVIP: presenceItem.isVIP,
};
})
),
@ -60,8 +60,8 @@ export async function loader({ context, params, request }: LoaderFunctionArgs) {
userFullName: name,
userId: userId,
userImageUrl: image,
isAdmin: metadata.isAdmin ? 1 : 0,
isVIP: metadata.isVIP ? 1 : 0,
isAdmin: metadata.isAdmin,
isVIP: metadata.isVIP,
})
.onConflictDoUpdate({
target: [presence.userId, presence.roomId],
@ -70,8 +70,8 @@ export async function loader({ context, params, request }: LoaderFunctionArgs) {
userFullName: name,
userId: userId,
userImageUrl: image,
isAdmin: metadata.isAdmin ? 1 : 0,
isVIP: metadata.isVIP ? 1 : 0,
isAdmin: metadata.isAdmin,
isVIP: metadata.isVIP,
},
})
.then(async () => {

View file

@ -37,7 +37,7 @@ export async function action({ request, params, context }: ActionFunctionArgs) {
},
});
const success = upsertResult.rowsAffected > 0;
const success = upsertResult.count > 0;
if (success) {
emitter.emit("nodes", "votes");

View file

@ -1,11 +1,7 @@
import { drizzle } from "drizzle-orm/libsql";
import { createClient } from "@libsql/client";
import { drizzle } from 'drizzle-orm/postgres-js';
import postgres from 'postgres';
import * as schema from "./schema.server";
import "dotenv/config";
const client = createClient({
url: process.env.DATABASE_URL!,
authToken: process.env.DATABASE_AUTH_TOKEN!,
});
export const db = drizzle(client, { schema });
const queryClient = postgres(process.env.DATABASE_URL!);
export const db = drizzle(queryClient, { schema });

View file

@ -1,20 +1,20 @@
import {
sqliteTable,
integer,
pgTable,
text,
unique,
index,
} from "drizzle-orm/sqlite-core";
boolean
} from "drizzle-orm/pg-core";
import { relations } from "drizzle-orm";
export const rooms = sqliteTable("Room", {
id: text("id", { length: 255 }).notNull().primaryKey(),
export const rooms = pgTable("Room", {
id: text("id").notNull().primaryKey(),
created_at: text("created_at"),
userId: text("userId", { length: 255 }).notNull(),
roomName: text("roomName", { length: 255 }),
storyName: text("storyName", { length: 255 }),
visible: integer("visible").default(0).notNull(),
scale: text("scale", { length: 255 }).default("0.5,1,2,3,5").notNull(),
userId: text("userId").notNull(),
roomName: text("roomName"),
storyName: text("storyName"),
visible: boolean("visible").default(false).notNull(),
scale: text("scale").default("0.5,1,2,3,5").notNull(),
});
export const roomsRelations = relations(rooms, ({ many }) => ({
@ -22,16 +22,16 @@ export const roomsRelations = relations(rooms, ({ many }) => ({
logs: many(logs),
}));
export const votes = sqliteTable(
export const votes = pgTable(
"Vote",
{
id: text("id", { length: 255 }).notNull().primaryKey(),
id: text("id").notNull().primaryKey(),
created_at: text("created_at"),
userId: text("userId", { length: 255 }).notNull(),
roomId: text("roomId", { length: 255 })
userId: text("userId").notNull(),
roomId: text("roomId")
.notNull()
.references(() => rooms.id, { onDelete: "cascade" }),
value: text("value", { length: 255 }).notNull(),
value: text("value").notNull(),
},
(table) => {
return {
@ -48,17 +48,17 @@ export const votesRelations = relations(votes, ({ one }) => ({
}),
}));
export const logs = sqliteTable(
export const logs = pgTable(
"Log",
{
id: text("id", { length: 255 }).notNull().primaryKey(),
id: text("id").notNull().primaryKey(),
created_at: text("created_at"),
userId: text("userId", { length: 255 }).notNull(),
roomId: text("roomId", { length: 255 }).notNull(),
scale: text("scale", { length: 255 }),
userId: text("userId").notNull(),
roomId: text("roomId").notNull(),
scale: text("scale"),
votes: text("votes"),
roomName: text("roomName", { length: 255 }),
storyName: text("storyName", { length: 255 }),
roomName: text("roomName"),
storyName: text("storyName"),
},
(table) => {
return {
@ -74,16 +74,16 @@ export const logsRelations = relations(logs, ({ one }) => ({
}),
}));
export const presence = sqliteTable(
export const presence = pgTable(
"Presence",
{
id: text("id", { length: 255 }).notNull().primaryKey(),
userId: text("userId", { length: 255 }).notNull(),
userFullName: text("userFullName", { length: 255 }).notNull(),
userImageUrl: text("userImageUrl", { length: 255 }).notNull(),
isVIP: integer("isVIP").default(0).notNull(),
isAdmin: integer("isAdmin").default(0).notNull(),
roomId: text("roomId", { length: 255 })
id: text("id").notNull().primaryKey(),
userId: text("userId").notNull(),
userFullName: text("userFullName").notNull(),
userImageUrl: text("userImageUrl").notNull(),
isVIP: boolean("isVIP").default(false).notNull(),
isAdmin: boolean("isAdmin").default(false).notNull(),
roomId: text("roomId")
.notNull()
.references(() => rooms.id, { onDelete: "cascade" }),
},

View file

@ -2,12 +2,11 @@ import type { Config } from "drizzle-kit";
import "dotenv/config";
export default {
schema: "./app/services/schema.ts",
schema: "./app/services/schema.server.ts",
out: "./drizzle/generated",
driver: "turso",
driver: "pg",
breakpoints: true,
dbCredentials: {
url: `${process.env.DATABASE_URL}`,
authToken: `${process.env.DATABASE_AUTH_TOKEN}`,
connectionString: `${process.env.DATABASE_URL}`,
},
} satisfies Config;

View file

@ -1,6 +1,6 @@
{
"name": "sprintpadawan",
"version": "4.2.2",
"version": "4.3.0",
"private": true,
"sideEffects": false,
"type": "module",
@ -12,38 +12,37 @@
},
"dependencies": {
"@clerk/remix": "^3.1.13",
"@libsql/client": "0.4.0-pre.5",
"@paralleldrive/cuid2": "^2.2.2",
"@remix-run/node": "^2.4.1",
"@remix-run/react": "^2.4.1",
"@remix-run/serve": "^2.4.1",
"csv42": "^5.0.0",
"dotenv": "^16.3.1",
"drizzle-orm": "^0.29.2",
"drizzle-orm": "^0.29.3",
"ioredis": "^5.3.2",
"isbot": "3.7.1-deprecated",
"lucide-react": "^0.302.0",
"lucide-react": "^0.306.0",
"postgres": "^3.4.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"remix-utils": "^7.4.0",
"remix-utils": "^7.5.0",
"svix": "^1.15.0"
},
"devDependencies": {
"@flydotio/dockerfile": "^0.5.0",
"@remix-run/dev": "^2.4.1",
"@remix-run/eslint-config": "^2.4.1",
"@types/react": "^18.2.45",
"@types/react": "^18.2.46",
"@types/react-dom": "^18.2.18",
"autoprefixer": "^10.4.16",
"better-sqlite3": "^9.2.2",
"daisyui": "^4.4.24",
"drizzle-kit": "^0.20.8",
"daisyui": "^4.5.0",
"drizzle-kit": "^0.20.10",
"eslint": "^8.56.0",
"postcss": "^8.4.32",
"tailwindcss": "^3.4.0",
"postcss": "^8.4.33",
"tailwindcss": "^3.4.1",
"typescript": "^5.3.3",
"vite": "^5.0.10",
"vite-tsconfig-paths": "^4.2.2"
"vite": "^5.0.11",
"vite-tsconfig-paths": "^4.2.3"
},
"engines": {
"node": ">=18.0.0"

4939
pnpm-lock.yaml generated

File diff suppressed because it is too large Load diff