Moved to Fly Postgres
This commit is contained in:
parent
c3093b95b1
commit
f286fcac34
9 changed files with 603 additions and 4457 deletions
|
@ -1,6 +1,5 @@
|
||||||
#Database
|
#Database
|
||||||
DATABASE_URL=""
|
DATABASE_URL=""
|
||||||
DATABASE_AUTH_TOKEN=""
|
|
||||||
REDIS_URL=""
|
REDIS_URL=""
|
||||||
|
|
||||||
#Auth
|
#Auth
|
||||||
|
|
|
@ -27,7 +27,7 @@ export async function action({ request, params, context }: ActionFunctionArgs) {
|
||||||
roomName: data.name,
|
roomName: data.name,
|
||||||
storyName: "First Story!",
|
storyName: "First Story!",
|
||||||
scale: "0.5,1,2,3,5,8",
|
scale: "0.5,1,2,3,5,8",
|
||||||
visible: 0,
|
visible: false,
|
||||||
})
|
})
|
||||||
.returning();
|
.returning();
|
||||||
|
|
||||||
|
|
|
@ -45,8 +45,8 @@ export async function loader({ context, params, request }: LoaderFunctionArgs) {
|
||||||
presenceData.map((presenceItem) => {
|
presenceData.map((presenceItem) => {
|
||||||
return {
|
return {
|
||||||
...presenceItem,
|
...presenceItem,
|
||||||
isAdmin: presenceItem.isAdmin === 0 ? false : true,
|
isAdmin: presenceItem.isAdmin,
|
||||||
isVIP: presenceItem.isVIP === 0 ? false : true,
|
isVIP: presenceItem.isVIP,
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
|
@ -60,8 +60,8 @@ export async function loader({ context, params, request }: LoaderFunctionArgs) {
|
||||||
userFullName: name,
|
userFullName: name,
|
||||||
userId: userId,
|
userId: userId,
|
||||||
userImageUrl: image,
|
userImageUrl: image,
|
||||||
isAdmin: metadata.isAdmin ? 1 : 0,
|
isAdmin: metadata.isAdmin,
|
||||||
isVIP: metadata.isVIP ? 1 : 0,
|
isVIP: metadata.isVIP,
|
||||||
})
|
})
|
||||||
.onConflictDoUpdate({
|
.onConflictDoUpdate({
|
||||||
target: [presence.userId, presence.roomId],
|
target: [presence.userId, presence.roomId],
|
||||||
|
@ -70,8 +70,8 @@ export async function loader({ context, params, request }: LoaderFunctionArgs) {
|
||||||
userFullName: name,
|
userFullName: name,
|
||||||
userId: userId,
|
userId: userId,
|
||||||
userImageUrl: image,
|
userImageUrl: image,
|
||||||
isAdmin: metadata.isAdmin ? 1 : 0,
|
isAdmin: metadata.isAdmin,
|
||||||
isVIP: metadata.isVIP ? 1 : 0,
|
isVIP: metadata.isVIP,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then(async () => {
|
.then(async () => {
|
||||||
|
|
|
@ -37,7 +37,7 @@ export async function action({ request, params, context }: ActionFunctionArgs) {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const success = upsertResult.rowsAffected > 0;
|
const success = upsertResult.count > 0;
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
emitter.emit("nodes", "votes");
|
emitter.emit("nodes", "votes");
|
||||||
|
|
|
@ -1,11 +1,7 @@
|
||||||
import { drizzle } from "drizzle-orm/libsql";
|
import { drizzle } from 'drizzle-orm/postgres-js';
|
||||||
import { createClient } from "@libsql/client";
|
import postgres from 'postgres';
|
||||||
import * as schema from "./schema.server";
|
import * as schema from "./schema.server";
|
||||||
import "dotenv/config";
|
import "dotenv/config";
|
||||||
|
|
||||||
const client = createClient({
|
const queryClient = postgres(process.env.DATABASE_URL!);
|
||||||
url: process.env.DATABASE_URL!,
|
export const db = drizzle(queryClient, { schema });
|
||||||
authToken: process.env.DATABASE_AUTH_TOKEN!,
|
|
||||||
});
|
|
||||||
|
|
||||||
export const db = drizzle(client, { schema });
|
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
import {
|
import {
|
||||||
sqliteTable,
|
pgTable,
|
||||||
integer,
|
|
||||||
text,
|
text,
|
||||||
unique,
|
unique,
|
||||||
index,
|
index,
|
||||||
} from "drizzle-orm/sqlite-core";
|
boolean
|
||||||
|
} from "drizzle-orm/pg-core";
|
||||||
import { relations } from "drizzle-orm";
|
import { relations } from "drizzle-orm";
|
||||||
|
|
||||||
export const rooms = sqliteTable("Room", {
|
export const rooms = pgTable("Room", {
|
||||||
id: text("id", { length: 255 }).notNull().primaryKey(),
|
id: text("id").notNull().primaryKey(),
|
||||||
created_at: text("created_at"),
|
created_at: text("created_at"),
|
||||||
userId: text("userId", { length: 255 }).notNull(),
|
userId: text("userId").notNull(),
|
||||||
roomName: text("roomName", { length: 255 }),
|
roomName: text("roomName"),
|
||||||
storyName: text("storyName", { length: 255 }),
|
storyName: text("storyName"),
|
||||||
visible: integer("visible").default(0).notNull(),
|
visible: boolean("visible").default(false).notNull(),
|
||||||
scale: text("scale", { length: 255 }).default("0.5,1,2,3,5").notNull(),
|
scale: text("scale").default("0.5,1,2,3,5").notNull(),
|
||||||
});
|
});
|
||||||
|
|
||||||
export const roomsRelations = relations(rooms, ({ many }) => ({
|
export const roomsRelations = relations(rooms, ({ many }) => ({
|
||||||
|
@ -22,16 +22,16 @@ export const roomsRelations = relations(rooms, ({ many }) => ({
|
||||||
logs: many(logs),
|
logs: many(logs),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const votes = sqliteTable(
|
export const votes = pgTable(
|
||||||
"Vote",
|
"Vote",
|
||||||
{
|
{
|
||||||
id: text("id", { length: 255 }).notNull().primaryKey(),
|
id: text("id").notNull().primaryKey(),
|
||||||
created_at: text("created_at"),
|
created_at: text("created_at"),
|
||||||
userId: text("userId", { length: 255 }).notNull(),
|
userId: text("userId").notNull(),
|
||||||
roomId: text("roomId", { length: 255 })
|
roomId: text("roomId")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => rooms.id, { onDelete: "cascade" }),
|
.references(() => rooms.id, { onDelete: "cascade" }),
|
||||||
value: text("value", { length: 255 }).notNull(),
|
value: text("value").notNull(),
|
||||||
},
|
},
|
||||||
(table) => {
|
(table) => {
|
||||||
return {
|
return {
|
||||||
|
@ -48,17 +48,17 @@ export const votesRelations = relations(votes, ({ one }) => ({
|
||||||
}),
|
}),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const logs = sqliteTable(
|
export const logs = pgTable(
|
||||||
"Log",
|
"Log",
|
||||||
{
|
{
|
||||||
id: text("id", { length: 255 }).notNull().primaryKey(),
|
id: text("id").notNull().primaryKey(),
|
||||||
created_at: text("created_at"),
|
created_at: text("created_at"),
|
||||||
userId: text("userId", { length: 255 }).notNull(),
|
userId: text("userId").notNull(),
|
||||||
roomId: text("roomId", { length: 255 }).notNull(),
|
roomId: text("roomId").notNull(),
|
||||||
scale: text("scale", { length: 255 }),
|
scale: text("scale"),
|
||||||
votes: text("votes"),
|
votes: text("votes"),
|
||||||
roomName: text("roomName", { length: 255 }),
|
roomName: text("roomName"),
|
||||||
storyName: text("storyName", { length: 255 }),
|
storyName: text("storyName"),
|
||||||
},
|
},
|
||||||
(table) => {
|
(table) => {
|
||||||
return {
|
return {
|
||||||
|
@ -74,16 +74,16 @@ export const logsRelations = relations(logs, ({ one }) => ({
|
||||||
}),
|
}),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
export const presence = sqliteTable(
|
export const presence = pgTable(
|
||||||
"Presence",
|
"Presence",
|
||||||
{
|
{
|
||||||
id: text("id", { length: 255 }).notNull().primaryKey(),
|
id: text("id").notNull().primaryKey(),
|
||||||
userId: text("userId", { length: 255 }).notNull(),
|
userId: text("userId").notNull(),
|
||||||
userFullName: text("userFullName", { length: 255 }).notNull(),
|
userFullName: text("userFullName").notNull(),
|
||||||
userImageUrl: text("userImageUrl", { length: 255 }).notNull(),
|
userImageUrl: text("userImageUrl").notNull(),
|
||||||
isVIP: integer("isVIP").default(0).notNull(),
|
isVIP: boolean("isVIP").default(false).notNull(),
|
||||||
isAdmin: integer("isAdmin").default(0).notNull(),
|
isAdmin: boolean("isAdmin").default(false).notNull(),
|
||||||
roomId: text("roomId", { length: 255 })
|
roomId: text("roomId")
|
||||||
.notNull()
|
.notNull()
|
||||||
.references(() => rooms.id, { onDelete: "cascade" }),
|
.references(() => rooms.id, { onDelete: "cascade" }),
|
||||||
},
|
},
|
||||||
|
|
|
@ -2,12 +2,11 @@ import type { Config } from "drizzle-kit";
|
||||||
import "dotenv/config";
|
import "dotenv/config";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
schema: "./app/services/schema.ts",
|
schema: "./app/services/schema.server.ts",
|
||||||
out: "./drizzle/generated",
|
out: "./drizzle/generated",
|
||||||
driver: "turso",
|
driver: "pg",
|
||||||
breakpoints: true,
|
breakpoints: true,
|
||||||
dbCredentials: {
|
dbCredentials: {
|
||||||
url: `${process.env.DATABASE_URL}`,
|
connectionString: `${process.env.DATABASE_URL}`,
|
||||||
authToken: `${process.env.DATABASE_AUTH_TOKEN}`,
|
|
||||||
},
|
},
|
||||||
} satisfies Config;
|
} satisfies Config;
|
||||||
|
|
25
package.json
25
package.json
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "sprintpadawan",
|
"name": "sprintpadawan",
|
||||||
"version": "4.2.2",
|
"version": "4.3.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
@ -12,38 +12,37 @@
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@clerk/remix": "^3.1.13",
|
"@clerk/remix": "^3.1.13",
|
||||||
"@libsql/client": "0.4.0-pre.5",
|
|
||||||
"@paralleldrive/cuid2": "^2.2.2",
|
"@paralleldrive/cuid2": "^2.2.2",
|
||||||
"@remix-run/node": "^2.4.1",
|
"@remix-run/node": "^2.4.1",
|
||||||
"@remix-run/react": "^2.4.1",
|
"@remix-run/react": "^2.4.1",
|
||||||
"@remix-run/serve": "^2.4.1",
|
"@remix-run/serve": "^2.4.1",
|
||||||
"csv42": "^5.0.0",
|
"csv42": "^5.0.0",
|
||||||
"dotenv": "^16.3.1",
|
"dotenv": "^16.3.1",
|
||||||
"drizzle-orm": "^0.29.2",
|
"drizzle-orm": "^0.29.3",
|
||||||
"ioredis": "^5.3.2",
|
"ioredis": "^5.3.2",
|
||||||
"isbot": "3.7.1-deprecated",
|
"isbot": "3.7.1-deprecated",
|
||||||
"lucide-react": "^0.302.0",
|
"lucide-react": "^0.306.0",
|
||||||
|
"postgres": "^3.4.3",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-dom": "^18.2.0",
|
"react-dom": "^18.2.0",
|
||||||
"remix-utils": "^7.4.0",
|
"remix-utils": "^7.5.0",
|
||||||
"svix": "^1.15.0"
|
"svix": "^1.15.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@flydotio/dockerfile": "^0.5.0",
|
"@flydotio/dockerfile": "^0.5.0",
|
||||||
"@remix-run/dev": "^2.4.1",
|
"@remix-run/dev": "^2.4.1",
|
||||||
"@remix-run/eslint-config": "^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",
|
"@types/react-dom": "^18.2.18",
|
||||||
"autoprefixer": "^10.4.16",
|
"autoprefixer": "^10.4.16",
|
||||||
"better-sqlite3": "^9.2.2",
|
"daisyui": "^4.5.0",
|
||||||
"daisyui": "^4.4.24",
|
"drizzle-kit": "^0.20.10",
|
||||||
"drizzle-kit": "^0.20.8",
|
|
||||||
"eslint": "^8.56.0",
|
"eslint": "^8.56.0",
|
||||||
"postcss": "^8.4.32",
|
"postcss": "^8.4.33",
|
||||||
"tailwindcss": "^3.4.0",
|
"tailwindcss": "^3.4.1",
|
||||||
"typescript": "^5.3.3",
|
"typescript": "^5.3.3",
|
||||||
"vite": "^5.0.10",
|
"vite": "^5.0.11",
|
||||||
"vite-tsconfig-paths": "^4.2.2"
|
"vite-tsconfig-paths": "^4.2.3"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.0.0"
|
"node": ">=18.0.0"
|
||||||
|
|
4939
pnpm-lock.yaml
generated
4939
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue