Progress on Colors api

This commit is contained in:
Ryan Pandya 2024-11-22 02:41:09 -08:00
parent 0802e36796
commit de9dca5274
56 changed files with 1492 additions and 4166 deletions

5
apps/cli/.env.local~ Normal file
View File

@ -0,0 +1,5 @@
SERVER_VERSION=0.1.0
DATA_DIR=/home/ryan/Notes/lifetracker
AUTH_SECRET=ryanisthebest
LIFETRACKER_API_KEY=ak1_b9b17eb909ce0ecdbf33_789b3a1f59390aad84be
LIFETRACKER_SERVER_ADDR=localhost

View File

@ -18,7 +18,9 @@
"dependencies": {
"@lifetracker/db": "workspace:*",
"@lifetracker/trpc": "workspace:^",
"vite-tsconfig-paths": "^5.1.0"
"table": "^6.8.2",
"vite-tsconfig-paths": "^5.1.0",
"dotenv": "^16.4.1"
},
"devDependencies": {
"@commander-js/extra-typings": "^12.1.0",

View File

@ -0,0 +1,77 @@
import { getGlobalOptions } from "@/lib/globals";
import {
printError,
printErrorMessageWithReason,
printObject,
printSuccess,
} from "@/lib/output";
import { getAPIClient } from "@/lib/trpc";
import { Command } from "@commander-js/extra-typings";
import { getBorderCharacters, table } from "table";
export const colorsCmd = new Command()
.name("colors")
.description("Manipulate custom colors");
colorsCmd
.command("list")
.description("lists all custom colors")
.action(async () => {
const api = getAPIClient();
try {
const colors = (await api.colors.list.query()).colors;
colors.sort((a, b) => b.numCategories - a.numCategories);
if (getGlobalOptions().json) {
printObject(colors);
} else {
const data: string[][] = [["Id", "Name", "Hexcode", "Num categories"]];
colors.forEach((color) => {
data.push([color.id, color.name, color.hexcode, color.numCategories.toString()]);
});
console.log(
data.length <= 1 ?
"No colors found. Add one with `lifetracker colors create <name> <hexcode>`" :
table(data, {
border: getBorderCharacters("ramac"),
singleLine: true,
}),
);
}
} catch (error) {
printErrorMessageWithReason("Failed to list all colors", error as object);
}
});
colorsCmd
.command("create")
.description("create a color")
.argument("<name>", "the name of the color")
.argument("<hexcode>", "the hexcode of the color")
.action(async (name: string, hexcode: string) => {
const api = getAPIClient();
await api.colors.create
.mutate({
name: name,
hexcode: hexcode,
})
.then(printSuccess(`Successfully created the color "${name}"`))
.catch(printError(`Failed to create the color "${name}"`));
});
// colorsCmd
// .command("delete")
// .description("delete a color")
// .argument("<id>", "the id of the color")
// .action(async (id) => {
// const api = getAPIClient();
// await api.colors.delete
// .mutate({
// colorId: id,
// })
// .then(printSuccess(`Successfully deleted the color with the id "${id}"`))
// .catch(printError(`Failed to delete the color with the id "${id}"`));
// });

View File

@ -0,0 +1,26 @@
import {
printError,
printErrorMessageWithReason,
printObject,
} from "@/lib/output";
import { getAPIClient } from "@/lib/trpc";
import { Command } from "@commander-js/extra-typings";
export const resetCmd = new Command()
.name("reset")
.description("Initializes the database with default data")
.action(async () => {
await getAPIClient()
.users.create.mutate({
email: "ryan@ryanpandya.com",
name: "Ryan Pandya",
password: "pleasework",
confirmPassword: "pleasework",
})
.then(printObject)
.catch(
printError(
`Unable to create user for Ryan`,
),
);
});

View File

@ -1,7 +1,16 @@
import { whoamiCmd } from "@/commands/whoami";
import { setGlobalOptions } from "@/lib/globals";
import { Command, Option } from "@commander-js/extra-typings";
import { whoamiCmd } from "@/commands/whoami";
import { colorsCmd } from "@/commands/colors";
import { config } from "dotenv";
config({
path: "./.env.local",
}
)
const program = new Command()
.name("lifetracker")
.description("A CLI interface to interact with my lifetracker api")
@ -28,6 +37,9 @@ const program = new Command()
program.addCommand(whoamiCmd, {
isDefault: true
});
program.addCommand(colorsCmd);
setGlobalOptions(program.opts());

View File

@ -0,0 +1,10 @@
import React from "react";
import CategoriesView from "@/components/dashboard/categories/CategoriesView";
export default async function CategoriesPage() {
return (
<div>
<CategoriesView />
</div>
);
}

View File

@ -1,10 +0,0 @@
import React from "react";
import LabelsView from "@/components/dashboard/labels/LabelsView";
export default async function LabelsPage() {
return (
<div>
<LabelsView />
</div>
);
}

View File

@ -0,0 +1,9 @@
import ColorSettings from "@/components/settings/ColorSettings";
export default async function ColorsPage() {
return (
<div className="rounded-md border bg-background p-4">
<ColorSettings />
</div>
);
}

View File

@ -33,25 +33,25 @@ import { TRPCClientError } from "@trpc/client";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { zLabelSchema } from "@lifetracker/shared/types/labels";
import { zCategorySchema } from "@lifetracker/shared/types/categories";
import { Textarea } from "@/components/ui/textarea";
type CreateLabelSchema = z.infer<typeof zLabelSchema>;
type CreateCategorySchema = z.infer<typeof zCategorySchema>;
export default function AddLabelDialog({
export default function AddCategoryDialog({
children,
}: {
children?: React.ReactNode;
}) {
const apiUtils = api.useUtils();
const [isOpen, onOpenChange] = useState(false);
const form = useForm<CreateLabelSchema>({
resolver: zodResolver(zLabelSchema),
const form = useForm<CreateCategorySchema>({
resolver: zodResolver(zCategorySchema),
});
const { mutate, isPending } = api.labels.createLabel.useMutation({
const { mutate, isPending } = api.categories.createCategory.useMutation({
onSuccess: () => {
toast({
description: "Label created successfully",
description: "Category created successfully",
});
onOpenChange(false);
},
@ -64,7 +64,7 @@ export default function AddLabelDialog({
} else {
toast({
variant: "destructive",
description: "Failed to create label",
description: "Failed to create category",
});
}
},
@ -81,7 +81,7 @@ export default function AddLabelDialog({
<DialogTrigger asChild>{children}</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>Create Label</DialogTitle>
<DialogTitle>Create Category</DialogTitle>
</DialogHeader>
<Form {...form}>
<form onSubmit={form.handleSubmit((val) => mutate(val))}>

View File

@ -0,0 +1,110 @@
"use client";
import { ActionButtonWithTooltip } from "@/components/ui/action-button";
import { ButtonWithTooltip } from "@/components/ui/button";
import LoadingSpinner from "@/components/ui/spinner";
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table";
import { toast } from "@/components/ui/use-toast";
import { api } from "@/lib/trpc";
import { Pencil, Trash, FilePlus, Palette } from "lucide-react";
import { useSession } from "next-auth/react";
import AddCategoryDialog from "./AddCategoryDialog";
import EditCategoryDialog from "./EditCategoryDialog";
import Link from "next/link";
export default function CategoriesView() {
const { data: session } = useSession();
const { data: categories } = api.categories.list.useQuery();
const { data: categoryStats } = api.categories.categoryStats.useQuery();
const invalidateCategoryList = api.useUtils().categories.list.invalidate;
const { mutate: deleteCategory, isPending: isDeletionPending } =
api.categories.delete.useMutation({
onSuccess: () => {
toast({
description: "Category deleted",
});
invalidateCategoryList();
},
onError: (e) => {
toast({
variant: "destructive",
description: `Something went wrong: ${e.message}`,
});
},
});
const CategoriesTable = ({ categories }) => (
<Table>
<TableHeader className="bg-gray-200">
<TableHead>Code</TableHead>
<TableHead>Name</TableHead>
<TableHead>Description</TableHead>
<TableHead>Entries</TableHead>
<TableHead>Actions</TableHead>
</TableHeader>
<TableBody>
{categories.categories.map((c) => (
<TableRow key={c.id} style={{ backgroundColor: c.color }}>
<TableCell className="py-1">{c.code}</TableCell>
<TableCell className="py-1">{c.name}</TableCell>
<TableCell className="py-1">{c.description}</TableCell>
<TableCell className="py-1">
{categoryStats[c.id].numEntries}
</TableCell>
<TableCell className="flex gap-1 py-1">
<ActionButtonWithTooltip
tooltip="Delete category"
variant="outline"
onClick={() => deleteCategory({ categoryId: c.id })}
loading={false}
>
<Trash size={16} color="red" />
</ActionButtonWithTooltip>
<EditCategoryDialog categoryId={c.id} >
<ButtonWithTooltip
tooltip="Edit"
variant="outline"
>
<Pencil size={16} color="red" />
</ButtonWithTooltip>
</EditCategoryDialog>
</TableCell>
</TableRow>
))}
</TableBody>
</Table >
);
return (
<>
<div className="mb-2 flex items-center justify-between text-xl font-medium">
<span>All Categories</span>
<div className="flex">
<ButtonWithTooltip tooltip="Edit colors" variant="outline">
<Link href="/settings/colors">
<Palette size={16} />
</Link>
</ButtonWithTooltip>
<AddCategoryDialog>
<ButtonWithTooltip tooltip="Create category" variant="outline">
<FilePlus size={16} />
</ButtonWithTooltip>
</AddCategoryDialog>
</div></div>
{categories === undefined ? (
<LoadingSpinner />
) : (
<CategoriesTable categories={categories} />
)}
</>
);
}

View File

@ -3,7 +3,7 @@ import { ActionButton } from "@/components/ui/action-button";
import ActionConfirmingDialog from "@/components/ui/action-confirming-dialog";
import { toast } from "@/components/ui/use-toast";
import { useDeleteLabel } from "@lifetracker/shared-react/hooks/labels";
import { useDeleteLabel } from "@lifetracker/shared-react/hooks/categories";
export default function DeleteLabelConfirmationDialog({
label,

View File

@ -33,31 +33,24 @@ import { TRPCClientError } from "@trpc/client";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { zLabelSchema } from "@lifetracker/shared/types/labels";
import { zLabelSchema } from "@lifetracker/shared/types/categories";
type CreateLabelSchema = z.infer<typeof zLabelSchema>;
type CreateLabelSchema = z.infer<typeof zCategorySchema>;
export default function EditLabelDialog({
export default function EditCategoryDialog({
children,
}: {
children?: React.ReactNode;
}) {
const apiUtils = api.useUtils();
const [isOpen, onOpenChange] = useState(false);
const form = useForm<CreateLabelSchema>({
resolver: zodResolver(zLabelSchema),
defaultValues: {
id: "69",
name: "Fuckdicks",
code: 420,
description: "This shit sucks",
color: "#004400",
},
const form = useForm<CreateCategorySchema>({
resolver: zodResolver(zCategorySchema),
});
const { mutate, isPending } = api.labels.update.useMutation({
const { mutate, isPending } = api.categories.update.useMutation({
onSuccess: () => {
toast({
description: "Label updated successfully",
description: "Category updated successfully",
});
onOpenChange(false);
},
@ -70,7 +63,7 @@ export default function EditLabelDialog({
} else {
toast({
variant: "destructive",
description: "Failed to update label",
description: "Failed to update category",
});
}
},
@ -87,7 +80,7 @@ export default function EditLabelDialog({
<DialogTrigger asChild>{children}</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>Edit Label</DialogTitle>
<DialogTitle>Edit Category</DialogTitle>
</DialogHeader>
<Form {...form}>
<form onSubmit={form.handleSubmit((val) => mutate(val))}>
@ -151,7 +144,7 @@ export default function EditLabelDialog({
name="color"
render={({ field }) => (
<FormItem>
<FormLabel>Color, hope you like hex codes</FormLabel>
<FormLabel>Color</FormLabel>
<FormControl>
<Input
type="text"

View File

@ -1,106 +0,0 @@
"use client";
import { ActionButtonWithTooltip } from "@/components/ui/action-button";
import { ButtonWithTooltip } from "@/components/ui/button";
import LoadingSpinner from "@/components/ui/spinner";
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table";
import { toast } from "@/components/ui/use-toast";
import { api } from "@/lib/trpc";
import { Check, KeyRound, Pencil, Trash, FilePlus, X } from "lucide-react";
import { useSession } from "next-auth/react";
import AddLabelDialog from "./AddLabelDialog";
import EditLabelDialog from "./EditLabelDialog";
import DeleteLabelConfirmationDialog from "./DeleteLabelConfirmationDialog";
export default function LabelsView() {
const { data: session } = useSession();
const { data: labels } = api.labels.list.useQuery();
const { data: labelStats } = api.labels.labelStats.useQuery();
const invalidateLabelList = api.useUtils().labels.list.invalidate;
const { mutate: deleteLabel, isPending: isDeletionPending } =
api.labels.delete.useMutation({
onSuccess: () => {
toast({
description: "Label deleted",
});
invalidateLabelList();
},
onError: (e) => {
toast({
variant: "destructive",
description: `Something went wrong: ${e.message}`,
});
},
});
const LabelsTable = ({ labels }) => (
<Table>
<TableHeader className="bg-gray-200">
<TableHead>Parent</TableHead>
<TableHead>Code</TableHead>
<TableHead>Name</TableHead>
<TableHead>Description</TableHead>
<TableHead>Entries With Label</TableHead>
<TableHead>Actions</TableHead>
</TableHeader>
<TableBody>
{labels.labels.map((l) => (
<TableRow key={l.id} style={{ backgroundColor: l.color }}>
<TableCell className="py-1">{l.parent}</TableCell>
<TableCell className="py-1">{l.code}</TableCell>
<TableCell className="py-1">{l.name}</TableCell>
<TableCell className="py-1">{l.description}</TableCell>
<TableCell className="py-1">
{labelStats[l.id].numEntries}
</TableCell>
<TableCell className="flex gap-1 py-1">
<ActionButtonWithTooltip
tooltip="Delete label"
variant="outline"
onClick={() => deleteLabel({ labelId: l.id })}
loading={false}
>
<Trash size={16} color="red" />
</ActionButtonWithTooltip>
<EditLabelDialog labelId={l.id} >
<ButtonWithTooltip
tooltip="Edit"
variant="outline"
>
<Pencil size={16} color="red" />
</ButtonWithTooltip>
</EditLabelDialog>
</TableCell>
</TableRow>
))}
</TableBody>
</Table >
);
return (
<>
<div className="mb-2 flex items-center justify-between text-xl font-medium">
<span>All Labels</span>
<AddLabelDialog>
<ButtonWithTooltip tooltip="Create Label" variant="outline">
<FilePlus size={16} />
</ButtonWithTooltip>
</AddLabelDialog>
</div>
{labels === undefined ? (
<LoadingSpinner />
) : (
<LabelsTable labels={labels} />
)}
</>
);
}

View File

@ -39,9 +39,9 @@ export default async function Sidebar() {
},
...searchItem,
{
name: "Labels",
name: "Categories",
icon: <Tag size={18} />,
path: "/dashboard/labels",
path: "/dashboard/categories",
},
];

View File

@ -0,0 +1,168 @@
import { useEffect, useState } from "react";
import { ActionButton } from "@/components/ui/action-button";
import { Button } from "@/components/ui/button";
import {
Dialog,
DialogClose,
DialogContent,
DialogFooter,
DialogHeader,
DialogTitle,
DialogTrigger,
} from "@/components/ui/dialog";
import {
Form,
FormControl,
FormField,
FormItem,
FormLabel,
FormMessage,
} from "@/components/ui/form";
import { Input } from "@/components/ui/input";
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select";
import { toast } from "@/components/ui/use-toast";
import { api } from "@/lib/trpc";
import { zodResolver } from "@hookform/resolvers/zod";
import { TRPCClientError } from "@trpc/client";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { titleCase } from "title-case";
import { zColorSchema, ZColor } from "@lifetracker/shared/types/colors";
import { HexColorPicker, HexColorInput } from 'react-colorful';
import { closest } from 'color-2-name';
export default function AddCategoryDialog({
children,
}: {
children?: React.ReactNode;
}) {
const apiUtils = api.useUtils();
const [isOpen, onOpenChange] = useState(false);
const [color, setColor] = useState("#000000");
const [guessedName, setGuessedName] = useState("Name");
const form = useForm<ZColor>({
resolver: zodResolver(zColorSchema),
});
const { mutate, isPending } = api.colors.create.useMutation({
onSuccess: () => {
toast({
description: "Color created successfully",
});
onOpenChange(false);
apiUtils.colors.list.invalidate();
},
onError: (error) => {
if (error instanceof TRPCClientError) {
toast({
variant: "destructive",
description: error.message,
});
} else {
toast({
variant: "destructive",
description: "Failed to create color",
});
}
},
});
useEffect(() => {
if (!isOpen) {
form.reset();
}
}, [isOpen, form]);
return (
<Dialog open={isOpen} onOpenChange={onOpenChange}>
<DialogTrigger asChild>{children}</DialogTrigger>
<DialogContent>
<DialogHeader>
<DialogTitle>Create Color</DialogTitle>
</DialogHeader>
<Form {...form}>
<form onSubmit={form.handleSubmit((val) => mutate(val))}>
<div className="flex w-full flex-col space-y-2">
<FormField
control={form.control}
name="name"
render={({ field }) => (
<div className="flex gap-2">
<FormItem
className="flex-1">
<FormControl>
<Input
type="text"
{...field}
value={guessedName}
className="w-full rounded border p-2"
/>
</FormControl>
<FormMessage />
</FormItem>
<ActionButton
type="button"
className="flex-0"
loading={false}
onClick={() => {
setGuessedName(titleCase(closest(color).name));
field.onChange(titleCase(closest(color).name));
}}
>
Guess
</ActionButton>
</div>
)}
/>
<FormField
control={form.control}
name="hexcode"
render={({ field }) => (
<FormItem>
<div className="flex flex-col items-center">
{/* <FormLabel>Description</FormLabel> */}
<HexColorInput color={color} onChange={
(newColor) => {
setColor(newColor);
field.onChange(newColor);
}}
prefixed className="flex h-10 border-input bg-background text-sm ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 w-full rounded border p-2" />
<HexColorPicker color={color} onChange={
(newColor) => {
setColor(newColor);
field.onChange(newColor);
}}
className="w-full" />
<FormMessage />
</div>
</FormItem>
)}
/>
<DialogFooter className="sm:justify-end">
<DialogClose asChild>
<Button type="button" variant="secondary">
Close
</Button>
</DialogClose>
<ActionButton
type="submit"
loading={isPending}
disabled={isPending}
>
Create
</ActionButton>
</DialogFooter>
</div>
</form>
</Form>
</DialogContent>
</Dialog>
);
}

View File

@ -0,0 +1,94 @@
"use client";
import { ActionButtonWithTooltip } from "@/components/ui/action-button";
import { ButtonWithTooltip } from "@/components/ui/button";
import LoadingSpinner from "@/components/ui/spinner";
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table";
import { toast } from "@/components/ui/use-toast";
import { api } from "@/lib/trpc";
import { Pencil, Trash, FilePlus, Palette } from "lucide-react";
import { useSession } from "next-auth/react";
import AddColor from "./AddColor";
// import EditCategoryDialog from "./EditCategoryDialog";
import Link from "next/link";
export default function ColorssView() {
const { data: session } = useSession();
const { data: colors } = api.colors.list.useQuery();
// const invalidateColorList = api.useUtils().colors.list.invalidate;
// const { mutate: deleteColor, isPending: isDeletionPending } =
// api.colors.delete.useMutation({
// onSuccess: () => {
// toast({
// description: "Color deleted",
// });
// invalidateCategoryList();
// },
// onError: (e) => {
// toast({
// variant: "destructive",
// description: `Something went wrong: ${e.message}`,
// });
// },
// });
const ColorsTable = ({ colors }) => (
<Table>
<TableHeader className="bg-gray-200">
<TableHead>Name</TableHead>
<TableHead>Categories</TableHead>
<TableHead>Actions</TableHead>
</TableHeader>
<TableBody>
{colors.colors.map((c) => (
<TableRow key={c.id} style={{ backgroundColor: c.hexcode, color: c.inverse }}>
<TableCell className="py-1">{c.name}</TableCell>
<TableCell className="py-1">
numEntries
</TableCell>
<TableCell className="flex gap-1 py-1">
<ActionButtonWithTooltip
tooltip="Delete category"
variant="outline"
onClick={() => deleteColor({ colorId: c.id })}
loading={false}
>
<Trash size={16} color="red" />
</ActionButtonWithTooltip>
Edit
</TableCell>
</TableRow>
))}
</TableBody>
</Table >
);
return (
<>
<div className="mb-2 flex items-center justify-between text-xl font-medium">
<span>All Colors ({colors === undefined ? 0 : colors.colors.length})</span>
<div className="flex">
<AddColor>
<ButtonWithTooltip tooltip="New color" variant="outline">
<FilePlus size={16} />
</ButtonWithTooltip>
</AddColor>
</div></div >
{colors === undefined ? (
<LoadingSpinner />
) : (
<ColorsTable colors={colors} />
)
}
</>
);
}

View File

@ -4,6 +4,7 @@ import {
Download,
KeyRound,
User,
Palette,
} from "lucide-react";
export const settingsSidebarItems: {
@ -21,6 +22,11 @@ export const settingsSidebarItems: {
icon: <User size={18} />,
path: "/settings/info",
},
{
name: "Color Settings",
icon: <Palette size={18} />,
path: "/settings/colors",
},
{
name: "Import / Export",
icon: <Download size={18} />,

View File

@ -47,6 +47,7 @@
"cheerio": "^1.0.0",
"class-variance-authority": "^0.7.0",
"clsx": "^2.1.0",
"color-2-name": "^1.4.4",
"csv-parse": "^5.5.6",
"dayjs": "^1.11.10",
"drizzle-orm": "^0.33.0",
@ -74,6 +75,7 @@
"sharp": "^0.33.3",
"superjson": "^2.2.1",
"tailwind-merge": "^2.2.1",
"title-case": "^4.3.2",
"zod": "^3.22.4",
"zustand": "^4.5.1"
},

View File

@ -24,6 +24,42 @@ CREATE TABLE `apiKey` (
FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `category` (
`id` text PRIMARY KEY NOT NULL,
`createdAt` integer NOT NULL,
`name` text NOT NULL,
`code` integer NOT NULL,
`description` text,
`colorId` text NOT NULL,
`parentId` text,
`userId` text NOT NULL,
FOREIGN KEY (`colorId`) REFERENCES `color`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`parentId`) REFERENCES `category`(`id`) ON UPDATE no action ON DELETE no action,
FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `color` (
`id` text PRIMARY KEY NOT NULL,
`createdAt` integer NOT NULL,
`name` text NOT NULL,
`hexcode` text NOT NULL,
`inverse` text,
`userId` text NOT NULL,
FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE TABLE `config` (
`key` text PRIMARY KEY NOT NULL,
`value` text NOT NULL
);
--> statement-breakpoint
CREATE TABLE `day` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`mood` integer,
`date` text NOT NULL,
`comment` text NOT NULL
);
--> statement-breakpoint
CREATE TABLE `session` (
`sessionToken` text PRIMARY KEY NOT NULL,
`userId` text NOT NULL,
@ -50,4 +86,7 @@ CREATE TABLE `verificationToken` (
--> statement-breakpoint
CREATE UNIQUE INDEX `apiKey_keyId_unique` ON `apiKey` (`keyId`);--> statement-breakpoint
CREATE UNIQUE INDEX `apiKey_name_userId_unique` ON `apiKey` (`name`,`userId`);--> statement-breakpoint
CREATE UNIQUE INDEX `category_userId_name_unique` ON `category` (`userId`,`name`);--> statement-breakpoint
CREATE UNIQUE INDEX `color_userId_name_unique` ON `color` (`userId`,`name`);--> statement-breakpoint
CREATE UNIQUE INDEX `day_date_unique` ON `day` (`date`);--> statement-breakpoint
CREATE UNIQUE INDEX `user_email_unique` ON `user` (`email`);

View File

@ -1,4 +0,0 @@
CREATE TABLE `events` (
`id` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
`description` text NOT NULL
);

View File

@ -1,5 +0,0 @@
ALTER TABLE `events` RENAME TO `days`;--> statement-breakpoint
ALTER TABLE `days` RENAME COLUMN `description` TO `comment`;--> statement-breakpoint
ALTER TABLE `days` ADD `mood` integer;--> statement-breakpoint
ALTER TABLE `days` ADD `date` text NOT NULL;--> statement-breakpoint
CREATE UNIQUE INDEX `days_date_unique` ON `days` (`date`);

View File

@ -1,3 +0,0 @@
ALTER TABLE `days` RENAME TO `day`;--> statement-breakpoint
DROP INDEX IF EXISTS `days_date_unique`;--> statement-breakpoint
CREATE UNIQUE INDEX `day_date_unique` ON `day` (`date`);

View File

@ -1,4 +0,0 @@
CREATE TABLE `config` (
`key` text PRIMARY KEY NOT NULL,
`value` text NOT NULL
);

View File

@ -1,11 +0,0 @@
CREATE TABLE `label` (
`id` text PRIMARY KEY NOT NULL,
`name` text NOT NULL,
`createdAt` integer NOT NULL,
`userId` text NOT NULL,
FOREIGN KEY (`userId`) REFERENCES `user`(`id`) ON UPDATE no action ON DELETE cascade
);
--> statement-breakpoint
CREATE INDEX `labels_name_idx` ON `label` (`name`);--> statement-breakpoint
CREATE INDEX `labels_userId_idx` ON `label` (`userId`);--> statement-breakpoint
CREATE UNIQUE INDEX `label_userId_name_unique` ON `label` (`userId`,`name`);

View File

@ -1,4 +0,0 @@
DROP INDEX IF EXISTS `labels_name_idx`;--> statement-breakpoint
DROP INDEX IF EXISTS `labels_userId_idx`;--> statement-breakpoint
ALTER TABLE `label` ADD `description` text;--> statement-breakpoint
ALTER TABLE `label` ADD `color` text DEFAULT '#000000';

View File

@ -1 +0,0 @@
ALTER TABLE `label` ADD `code` integer NOT NULL;

View File

@ -1,8 +0,0 @@
ALTER TABLE `label` ADD `parentId` text REFERENCES label(id);--> statement-breakpoint
/*
SQLite does not support "Creating foreign key on existing column" out of the box, we do not generate automatic migration for that, so it has to be done manually
Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
https://www.sqlite.org/lang_altertable.html
Due to that we don't generate migration automatically and it has to be done manually
*/

View File

@ -1,8 +0,0 @@
/*
SQLite does not support "Dropping foreign key" out of the box, we do not generate automatic migration for that, so it has to be done manually
Please refer to: https://www.techonthenet.com/sqlite/tables/alter_table.php
https://www.sqlite.org/lang_altertable.html
Due to that we don't generate migration automatically and it has to be done manually
*/--> statement-breakpoint
ALTER TABLE `label` DROP COLUMN `parentId`;

View File

@ -1,23 +1,400 @@
{
"version": "6",
"dialect": "sqlite",
"id": "74097c41-1958-4fc8-8371-6e31b3071eb9",
"id": "d35127c1-6892-410e-b933-d7ec7aabe6f5",
"prevId": "00000000-0000-0000-0000-000000000000",
"tables": {
"events": {
"name": "events",
"account": {
"name": "account",
"columns": {
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"type": {
"name": "type",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"provider": {
"name": "provider",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"providerAccountId": {
"name": "providerAccountId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"refresh_token": {
"name": "refresh_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"access_token": {
"name": "access_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"expires_at": {
"name": "expires_at",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"token_type": {
"name": "token_type",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"scope": {
"name": "scope",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"id_token": {
"name": "id_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"session_state": {
"name": "session_state",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"account_userId_user_id_fk": {
"name": "account_userId_user_id_fk",
"tableFrom": "account",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {
"account_provider_providerAccountId_pk": {
"columns": [
"provider",
"providerAccountId"
],
"name": "account_provider_providerAccountId_pk"
}
},
"uniqueConstraints": {}
},
"apiKey": {
"name": "apiKey",
"columns": {
"id": {
"name": "id",
"type": "integer",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": true
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"createdAt": {
"name": "createdAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"keyId": {
"name": "keyId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"keyHash": {
"name": "keyHash",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"apiKey_keyId_unique": {
"name": "apiKey_keyId_unique",
"columns": [
"keyId"
],
"isUnique": true
},
"apiKey_name_userId_unique": {
"name": "apiKey_name_userId_unique",
"columns": [
"name",
"userId"
],
"isUnique": true
}
},
"foreignKeys": {
"apiKey_userId_user_id_fk": {
"name": "apiKey_userId_user_id_fk",
"tableFrom": "apiKey",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"category": {
"name": "category",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"createdAt": {
"name": "createdAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"code": {
"name": "code",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"colorId": {
"name": "colorId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"parentId": {
"name": "parentId",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"category_userId_name_unique": {
"name": "category_userId_name_unique",
"columns": [
"userId",
"name"
],
"isUnique": true
}
},
"foreignKeys": {
"category_colorId_color_id_fk": {
"name": "category_colorId_color_id_fk",
"tableFrom": "category",
"tableTo": "color",
"columnsFrom": [
"colorId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"category_parentId_category_id_fk": {
"name": "category_parentId_category_id_fk",
"tableFrom": "category",
"tableTo": "category",
"columnsFrom": [
"parentId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"category_userId_user_id_fk": {
"name": "category_userId_user_id_fk",
"tableFrom": "category",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"color": {
"name": "color",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"createdAt": {
"name": "createdAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"hexcode": {
"name": "hexcode",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"inverse": {
"name": "inverse",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"color_userId_name_unique": {
"name": "color_userId_name_unique",
"columns": [
"userId",
"name"
],
"isUnique": true
}
},
"foreignKeys": {
"color_userId_user_id_fk": {
"name": "color_userId_user_id_fk",
"tableFrom": "color",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"config": {
"name": "config",
"columns": {
"key": {
"name": "key",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"value": {
"name": "value",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
@ -26,6 +403,200 @@
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"day": {
"name": "day",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": true
},
"mood": {
"name": "mood",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"date": {
"name": "date",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"comment": {
"name": "comment",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"day_date_unique": {
"name": "day_date_unique",
"columns": [
"date"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"session": {
"name": "session",
"columns": {
"sessionToken": {
"name": "sessionToken",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expires": {
"name": "expires",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"session_userId_user_id_fk": {
"name": "session_userId_user_id_fk",
"tableFrom": "session",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"user": {
"name": "user",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"emailVerified": {
"name": "emailVerified",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"image": {
"name": "image",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"password": {
"name": "password",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"role": {
"name": "role",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": "'user'"
}
},
"indexes": {
"user_email_unique": {
"name": "user_email_unique",
"columns": [
"email"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"verificationToken": {
"name": "verificationToken",
"columns": {
"identifier": {
"name": "identifier",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"token": {
"name": "token",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expires": {
"name": "expires",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {
"verificationToken_identifier_token_pk": {
"columns": [
"identifier",
"token"
],
"name": "verificationToken_identifier_token_pk"
}
},
"uniqueConstraints": {}
}
},
"enums": {},

View File

@ -1,66 +0,0 @@
{
"version": "6",
"dialect": "sqlite",
"id": "6ad45ca2-1f2d-4e94-a8fd-b749a8577a61",
"prevId": "74097c41-1958-4fc8-8371-6e31b3071eb9",
"tables": {
"days": {
"name": "days",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": true
},
"mood": {
"name": "mood",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"date": {
"name": "date",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"comment": {
"name": "comment",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"days_date_unique": {
"name": "days_date_unique",
"columns": [
"date"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
}
},
"enums": {},
"_meta": {
"schemas": {},
"tables": {
"\"events\"": "\"days\""
},
"columns": {
"\"days\".\"description\"": "\"days\".\"comment\""
}
},
"internal": {
"indexes": {}
}
}

View File

@ -1,400 +0,0 @@
{
"version": "6",
"dialect": "sqlite",
"id": "709a800b-1a51-4e31-96ef-0e8dd1c42a95",
"prevId": "6ad45ca2-1f2d-4e94-a8fd-b749a8577a61",
"tables": {
"account": {
"name": "account",
"columns": {
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"type": {
"name": "type",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"provider": {
"name": "provider",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"providerAccountId": {
"name": "providerAccountId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"refresh_token": {
"name": "refresh_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"access_token": {
"name": "access_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"expires_at": {
"name": "expires_at",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"token_type": {
"name": "token_type",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"scope": {
"name": "scope",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"id_token": {
"name": "id_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"session_state": {
"name": "session_state",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"account_userId_user_id_fk": {
"name": "account_userId_user_id_fk",
"tableFrom": "account",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {
"account_provider_providerAccountId_pk": {
"columns": [
"provider",
"providerAccountId"
],
"name": "account_provider_providerAccountId_pk"
}
},
"uniqueConstraints": {}
},
"apiKey": {
"name": "apiKey",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"createdAt": {
"name": "createdAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"keyId": {
"name": "keyId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"keyHash": {
"name": "keyHash",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"apiKey_keyId_unique": {
"name": "apiKey_keyId_unique",
"columns": [
"keyId"
],
"isUnique": true
},
"apiKey_name_userId_unique": {
"name": "apiKey_name_userId_unique",
"columns": [
"name",
"userId"
],
"isUnique": true
}
},
"foreignKeys": {
"apiKey_userId_user_id_fk": {
"name": "apiKey_userId_user_id_fk",
"tableFrom": "apiKey",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"session": {
"name": "session",
"columns": {
"sessionToken": {
"name": "sessionToken",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expires": {
"name": "expires",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"session_userId_user_id_fk": {
"name": "session_userId_user_id_fk",
"tableFrom": "session",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"user": {
"name": "user",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"emailVerified": {
"name": "emailVerified",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"image": {
"name": "image",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"password": {
"name": "password",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"role": {
"name": "role",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": "'user'"
}
},
"indexes": {
"user_email_unique": {
"name": "user_email_unique",
"columns": [
"email"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"verificationToken": {
"name": "verificationToken",
"columns": {
"identifier": {
"name": "identifier",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"token": {
"name": "token",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expires": {
"name": "expires",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {
"verificationToken_identifier_token_pk": {
"columns": [
"identifier",
"token"
],
"name": "verificationToken_identifier_token_pk"
}
},
"uniqueConstraints": {}
},
"days": {
"name": "days",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": true
},
"mood": {
"name": "mood",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"date": {
"name": "date",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"comment": {
"name": "comment",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"days_date_unique": {
"name": "days_date_unique",
"columns": [
"date"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
}
},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
},
"internal": {
"indexes": {}
}
}

View File

@ -1,402 +0,0 @@
{
"version": "6",
"dialect": "sqlite",
"id": "67edcacc-ad95-4e34-b368-4beeda535072",
"prevId": "709a800b-1a51-4e31-96ef-0e8dd1c42a95",
"tables": {
"account": {
"name": "account",
"columns": {
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"type": {
"name": "type",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"provider": {
"name": "provider",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"providerAccountId": {
"name": "providerAccountId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"refresh_token": {
"name": "refresh_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"access_token": {
"name": "access_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"expires_at": {
"name": "expires_at",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"token_type": {
"name": "token_type",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"scope": {
"name": "scope",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"id_token": {
"name": "id_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"session_state": {
"name": "session_state",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"account_userId_user_id_fk": {
"name": "account_userId_user_id_fk",
"tableFrom": "account",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {
"account_provider_providerAccountId_pk": {
"columns": [
"provider",
"providerAccountId"
],
"name": "account_provider_providerAccountId_pk"
}
},
"uniqueConstraints": {}
},
"apiKey": {
"name": "apiKey",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"createdAt": {
"name": "createdAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"keyId": {
"name": "keyId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"keyHash": {
"name": "keyHash",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"apiKey_keyId_unique": {
"name": "apiKey_keyId_unique",
"columns": [
"keyId"
],
"isUnique": true
},
"apiKey_name_userId_unique": {
"name": "apiKey_name_userId_unique",
"columns": [
"name",
"userId"
],
"isUnique": true
}
},
"foreignKeys": {
"apiKey_userId_user_id_fk": {
"name": "apiKey_userId_user_id_fk",
"tableFrom": "apiKey",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"session": {
"name": "session",
"columns": {
"sessionToken": {
"name": "sessionToken",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expires": {
"name": "expires",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"session_userId_user_id_fk": {
"name": "session_userId_user_id_fk",
"tableFrom": "session",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"user": {
"name": "user",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"emailVerified": {
"name": "emailVerified",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"image": {
"name": "image",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"password": {
"name": "password",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"role": {
"name": "role",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": "'user'"
}
},
"indexes": {
"user_email_unique": {
"name": "user_email_unique",
"columns": [
"email"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"verificationToken": {
"name": "verificationToken",
"columns": {
"identifier": {
"name": "identifier",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"token": {
"name": "token",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expires": {
"name": "expires",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {
"verificationToken_identifier_token_pk": {
"columns": [
"identifier",
"token"
],
"name": "verificationToken_identifier_token_pk"
}
},
"uniqueConstraints": {}
},
"day": {
"name": "day",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": true
},
"mood": {
"name": "mood",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"date": {
"name": "date",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"comment": {
"name": "comment",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"day_date_unique": {
"name": "day_date_unique",
"columns": [
"date"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
}
},
"enums": {},
"_meta": {
"schemas": {},
"tables": {
"\"days\"": "\"day\""
},
"columns": {}
},
"internal": {
"indexes": {}
}
}

View File

@ -1,423 +0,0 @@
{
"version": "6",
"dialect": "sqlite",
"id": "bcdf4680-869f-4b4a-9690-1bd45a196387",
"prevId": "67edcacc-ad95-4e34-b368-4beeda535072",
"tables": {
"account": {
"name": "account",
"columns": {
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"type": {
"name": "type",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"provider": {
"name": "provider",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"providerAccountId": {
"name": "providerAccountId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"refresh_token": {
"name": "refresh_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"access_token": {
"name": "access_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"expires_at": {
"name": "expires_at",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"token_type": {
"name": "token_type",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"scope": {
"name": "scope",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"id_token": {
"name": "id_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"session_state": {
"name": "session_state",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"account_userId_user_id_fk": {
"name": "account_userId_user_id_fk",
"tableFrom": "account",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {
"account_provider_providerAccountId_pk": {
"columns": [
"provider",
"providerAccountId"
],
"name": "account_provider_providerAccountId_pk"
}
},
"uniqueConstraints": {}
},
"apiKey": {
"name": "apiKey",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"createdAt": {
"name": "createdAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"keyId": {
"name": "keyId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"keyHash": {
"name": "keyHash",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"apiKey_keyId_unique": {
"name": "apiKey_keyId_unique",
"columns": [
"keyId"
],
"isUnique": true
},
"apiKey_name_userId_unique": {
"name": "apiKey_name_userId_unique",
"columns": [
"name",
"userId"
],
"isUnique": true
}
},
"foreignKeys": {
"apiKey_userId_user_id_fk": {
"name": "apiKey_userId_user_id_fk",
"tableFrom": "apiKey",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"config": {
"name": "config",
"columns": {
"key": {
"name": "key",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"value": {
"name": "value",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"day": {
"name": "day",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": true
},
"mood": {
"name": "mood",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"date": {
"name": "date",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"comment": {
"name": "comment",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"day_date_unique": {
"name": "day_date_unique",
"columns": [
"date"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"session": {
"name": "session",
"columns": {
"sessionToken": {
"name": "sessionToken",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expires": {
"name": "expires",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"session_userId_user_id_fk": {
"name": "session_userId_user_id_fk",
"tableFrom": "session",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"user": {
"name": "user",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"emailVerified": {
"name": "emailVerified",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"image": {
"name": "image",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"password": {
"name": "password",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"role": {
"name": "role",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": "'user'"
}
},
"indexes": {
"user_email_unique": {
"name": "user_email_unique",
"columns": [
"email"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"verificationToken": {
"name": "verificationToken",
"columns": {
"identifier": {
"name": "identifier",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"token": {
"name": "token",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expires": {
"name": "expires",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {
"verificationToken_identifier_token_pk": {
"columns": [
"identifier",
"token"
],
"name": "verificationToken_identifier_token_pk"
}
},
"uniqueConstraints": {}
}
},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
},
"internal": {
"indexes": {}
}
}

View File

@ -1,497 +0,0 @@
{
"version": "6",
"dialect": "sqlite",
"id": "06e873b5-ab39-469c-9437-bb1cf4bc60e8",
"prevId": "bcdf4680-869f-4b4a-9690-1bd45a196387",
"tables": {
"account": {
"name": "account",
"columns": {
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"type": {
"name": "type",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"provider": {
"name": "provider",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"providerAccountId": {
"name": "providerAccountId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"refresh_token": {
"name": "refresh_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"access_token": {
"name": "access_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"expires_at": {
"name": "expires_at",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"token_type": {
"name": "token_type",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"scope": {
"name": "scope",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"id_token": {
"name": "id_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"session_state": {
"name": "session_state",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"account_userId_user_id_fk": {
"name": "account_userId_user_id_fk",
"tableFrom": "account",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {
"account_provider_providerAccountId_pk": {
"columns": [
"provider",
"providerAccountId"
],
"name": "account_provider_providerAccountId_pk"
}
},
"uniqueConstraints": {}
},
"apiKey": {
"name": "apiKey",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"createdAt": {
"name": "createdAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"keyId": {
"name": "keyId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"keyHash": {
"name": "keyHash",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"apiKey_keyId_unique": {
"name": "apiKey_keyId_unique",
"columns": [
"keyId"
],
"isUnique": true
},
"apiKey_name_userId_unique": {
"name": "apiKey_name_userId_unique",
"columns": [
"name",
"userId"
],
"isUnique": true
}
},
"foreignKeys": {
"apiKey_userId_user_id_fk": {
"name": "apiKey_userId_user_id_fk",
"tableFrom": "apiKey",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"config": {
"name": "config",
"columns": {
"key": {
"name": "key",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"value": {
"name": "value",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"day": {
"name": "day",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": true
},
"mood": {
"name": "mood",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"date": {
"name": "date",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"comment": {
"name": "comment",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"day_date_unique": {
"name": "day_date_unique",
"columns": [
"date"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"label": {
"name": "label",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"createdAt": {
"name": "createdAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"labels_name_idx": {
"name": "labels_name_idx",
"columns": [
"name"
],
"isUnique": false
},
"labels_userId_idx": {
"name": "labels_userId_idx",
"columns": [
"userId"
],
"isUnique": false
},
"label_userId_name_unique": {
"name": "label_userId_name_unique",
"columns": [
"userId",
"name"
],
"isUnique": true
}
},
"foreignKeys": {
"label_userId_user_id_fk": {
"name": "label_userId_user_id_fk",
"tableFrom": "label",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"session": {
"name": "session",
"columns": {
"sessionToken": {
"name": "sessionToken",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expires": {
"name": "expires",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"session_userId_user_id_fk": {
"name": "session_userId_user_id_fk",
"tableFrom": "session",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"user": {
"name": "user",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"emailVerified": {
"name": "emailVerified",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"image": {
"name": "image",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"password": {
"name": "password",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"role": {
"name": "role",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": "'user'"
}
},
"indexes": {
"user_email_unique": {
"name": "user_email_unique",
"columns": [
"email"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"verificationToken": {
"name": "verificationToken",
"columns": {
"identifier": {
"name": "identifier",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"token": {
"name": "token",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expires": {
"name": "expires",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {
"verificationToken_identifier_token_pk": {
"columns": [
"identifier",
"token"
],
"name": "verificationToken_identifier_token_pk"
}
},
"uniqueConstraints": {}
}
},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
},
"internal": {
"indexes": {}
}
}

View File

@ -1,498 +0,0 @@
{
"version": "6",
"dialect": "sqlite",
"id": "22c67302-ebcd-4ad9-8393-feea41c17455",
"prevId": "06e873b5-ab39-469c-9437-bb1cf4bc60e8",
"tables": {
"account": {
"name": "account",
"columns": {
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"type": {
"name": "type",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"provider": {
"name": "provider",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"providerAccountId": {
"name": "providerAccountId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"refresh_token": {
"name": "refresh_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"access_token": {
"name": "access_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"expires_at": {
"name": "expires_at",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"token_type": {
"name": "token_type",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"scope": {
"name": "scope",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"id_token": {
"name": "id_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"session_state": {
"name": "session_state",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"account_userId_user_id_fk": {
"name": "account_userId_user_id_fk",
"tableFrom": "account",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {
"account_provider_providerAccountId_pk": {
"columns": [
"provider",
"providerAccountId"
],
"name": "account_provider_providerAccountId_pk"
}
},
"uniqueConstraints": {}
},
"apiKey": {
"name": "apiKey",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"createdAt": {
"name": "createdAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"keyId": {
"name": "keyId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"keyHash": {
"name": "keyHash",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"apiKey_keyId_unique": {
"name": "apiKey_keyId_unique",
"columns": [
"keyId"
],
"isUnique": true
},
"apiKey_name_userId_unique": {
"name": "apiKey_name_userId_unique",
"columns": [
"name",
"userId"
],
"isUnique": true
}
},
"foreignKeys": {
"apiKey_userId_user_id_fk": {
"name": "apiKey_userId_user_id_fk",
"tableFrom": "apiKey",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"config": {
"name": "config",
"columns": {
"key": {
"name": "key",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"value": {
"name": "value",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"day": {
"name": "day",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": true
},
"mood": {
"name": "mood",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"date": {
"name": "date",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"comment": {
"name": "comment",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"day_date_unique": {
"name": "day_date_unique",
"columns": [
"date"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"label": {
"name": "label",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"createdAt": {
"name": "createdAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"color": {
"name": "color",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": "'#000000'"
},
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"label_userId_name_unique": {
"name": "label_userId_name_unique",
"columns": [
"userId",
"name"
],
"isUnique": true
}
},
"foreignKeys": {
"label_userId_user_id_fk": {
"name": "label_userId_user_id_fk",
"tableFrom": "label",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"session": {
"name": "session",
"columns": {
"sessionToken": {
"name": "sessionToken",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expires": {
"name": "expires",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"session_userId_user_id_fk": {
"name": "session_userId_user_id_fk",
"tableFrom": "session",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"user": {
"name": "user",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"emailVerified": {
"name": "emailVerified",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"image": {
"name": "image",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"password": {
"name": "password",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"role": {
"name": "role",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": "'user'"
}
},
"indexes": {
"user_email_unique": {
"name": "user_email_unique",
"columns": [
"email"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"verificationToken": {
"name": "verificationToken",
"columns": {
"identifier": {
"name": "identifier",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"token": {
"name": "token",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expires": {
"name": "expires",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {
"verificationToken_identifier_token_pk": {
"columns": [
"identifier",
"token"
],
"name": "verificationToken_identifier_token_pk"
}
},
"uniqueConstraints": {}
}
},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
},
"internal": {
"indexes": {}
}
}

View File

@ -1,505 +0,0 @@
{
"version": "6",
"dialect": "sqlite",
"id": "d5294e8b-976b-4c92-bc82-b4e35e2683bb",
"prevId": "22c67302-ebcd-4ad9-8393-feea41c17455",
"tables": {
"account": {
"name": "account",
"columns": {
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"type": {
"name": "type",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"provider": {
"name": "provider",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"providerAccountId": {
"name": "providerAccountId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"refresh_token": {
"name": "refresh_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"access_token": {
"name": "access_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"expires_at": {
"name": "expires_at",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"token_type": {
"name": "token_type",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"scope": {
"name": "scope",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"id_token": {
"name": "id_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"session_state": {
"name": "session_state",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"account_userId_user_id_fk": {
"name": "account_userId_user_id_fk",
"tableFrom": "account",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {
"account_provider_providerAccountId_pk": {
"columns": [
"provider",
"providerAccountId"
],
"name": "account_provider_providerAccountId_pk"
}
},
"uniqueConstraints": {}
},
"apiKey": {
"name": "apiKey",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"createdAt": {
"name": "createdAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"keyId": {
"name": "keyId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"keyHash": {
"name": "keyHash",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"apiKey_keyId_unique": {
"name": "apiKey_keyId_unique",
"columns": [
"keyId"
],
"isUnique": true
},
"apiKey_name_userId_unique": {
"name": "apiKey_name_userId_unique",
"columns": [
"name",
"userId"
],
"isUnique": true
}
},
"foreignKeys": {
"apiKey_userId_user_id_fk": {
"name": "apiKey_userId_user_id_fk",
"tableFrom": "apiKey",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"config": {
"name": "config",
"columns": {
"key": {
"name": "key",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"value": {
"name": "value",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"day": {
"name": "day",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": true
},
"mood": {
"name": "mood",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"date": {
"name": "date",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"comment": {
"name": "comment",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"day_date_unique": {
"name": "day_date_unique",
"columns": [
"date"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"label": {
"name": "label",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"createdAt": {
"name": "createdAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"code": {
"name": "code",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"color": {
"name": "color",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": "'#000000'"
},
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"label_userId_name_unique": {
"name": "label_userId_name_unique",
"columns": [
"userId",
"name"
],
"isUnique": true
}
},
"foreignKeys": {
"label_userId_user_id_fk": {
"name": "label_userId_user_id_fk",
"tableFrom": "label",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"session": {
"name": "session",
"columns": {
"sessionToken": {
"name": "sessionToken",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expires": {
"name": "expires",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"session_userId_user_id_fk": {
"name": "session_userId_user_id_fk",
"tableFrom": "session",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"user": {
"name": "user",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"emailVerified": {
"name": "emailVerified",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"image": {
"name": "image",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"password": {
"name": "password",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"role": {
"name": "role",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": "'user'"
}
},
"indexes": {
"user_email_unique": {
"name": "user_email_unique",
"columns": [
"email"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"verificationToken": {
"name": "verificationToken",
"columns": {
"identifier": {
"name": "identifier",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"token": {
"name": "token",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expires": {
"name": "expires",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {
"verificationToken_identifier_token_pk": {
"columns": [
"identifier",
"token"
],
"name": "verificationToken_identifier_token_pk"
}
},
"uniqueConstraints": {}
}
},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
},
"internal": {
"indexes": {}
}
}

View File

@ -1,525 +0,0 @@
{
"version": "6",
"dialect": "sqlite",
"id": "fb2c8ded-5e0a-4d12-b729-a5d89be3ca14",
"prevId": "d5294e8b-976b-4c92-bc82-b4e35e2683bb",
"tables": {
"account": {
"name": "account",
"columns": {
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"type": {
"name": "type",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"provider": {
"name": "provider",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"providerAccountId": {
"name": "providerAccountId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"refresh_token": {
"name": "refresh_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"access_token": {
"name": "access_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"expires_at": {
"name": "expires_at",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"token_type": {
"name": "token_type",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"scope": {
"name": "scope",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"id_token": {
"name": "id_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"session_state": {
"name": "session_state",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"account_userId_user_id_fk": {
"name": "account_userId_user_id_fk",
"tableFrom": "account",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {
"account_provider_providerAccountId_pk": {
"columns": [
"provider",
"providerAccountId"
],
"name": "account_provider_providerAccountId_pk"
}
},
"uniqueConstraints": {}
},
"apiKey": {
"name": "apiKey",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"createdAt": {
"name": "createdAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"keyId": {
"name": "keyId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"keyHash": {
"name": "keyHash",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"apiKey_keyId_unique": {
"name": "apiKey_keyId_unique",
"columns": [
"keyId"
],
"isUnique": true
},
"apiKey_name_userId_unique": {
"name": "apiKey_name_userId_unique",
"columns": [
"name",
"userId"
],
"isUnique": true
}
},
"foreignKeys": {
"apiKey_userId_user_id_fk": {
"name": "apiKey_userId_user_id_fk",
"tableFrom": "apiKey",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"config": {
"name": "config",
"columns": {
"key": {
"name": "key",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"value": {
"name": "value",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"day": {
"name": "day",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": true
},
"mood": {
"name": "mood",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"date": {
"name": "date",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"comment": {
"name": "comment",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"day_date_unique": {
"name": "day_date_unique",
"columns": [
"date"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"label": {
"name": "label",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"createdAt": {
"name": "createdAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"code": {
"name": "code",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"color": {
"name": "color",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": "'#000000'"
},
"parentId": {
"name": "parentId",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"label_userId_name_unique": {
"name": "label_userId_name_unique",
"columns": [
"userId",
"name"
],
"isUnique": true
}
},
"foreignKeys": {
"label_parentId_label_id_fk": {
"name": "label_parentId_label_id_fk",
"tableFrom": "label",
"tableTo": "label",
"columnsFrom": [
"parentId"
],
"columnsTo": [
"id"
],
"onDelete": "no action",
"onUpdate": "no action"
},
"label_userId_user_id_fk": {
"name": "label_userId_user_id_fk",
"tableFrom": "label",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"session": {
"name": "session",
"columns": {
"sessionToken": {
"name": "sessionToken",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expires": {
"name": "expires",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"session_userId_user_id_fk": {
"name": "session_userId_user_id_fk",
"tableFrom": "session",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"user": {
"name": "user",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"emailVerified": {
"name": "emailVerified",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"image": {
"name": "image",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"password": {
"name": "password",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"role": {
"name": "role",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": "'user'"
}
},
"indexes": {
"user_email_unique": {
"name": "user_email_unique",
"columns": [
"email"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"verificationToken": {
"name": "verificationToken",
"columns": {
"identifier": {
"name": "identifier",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"token": {
"name": "token",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expires": {
"name": "expires",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {
"verificationToken_identifier_token_pk": {
"columns": [
"identifier",
"token"
],
"name": "verificationToken_identifier_token_pk"
}
},
"uniqueConstraints": {}
}
},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
},
"internal": {
"indexes": {}
}
}

View File

@ -1,505 +0,0 @@
{
"version": "6",
"dialect": "sqlite",
"id": "c4fbb77c-3439-446a-92e4-14a4b681f83e",
"prevId": "fb2c8ded-5e0a-4d12-b729-a5d89be3ca14",
"tables": {
"account": {
"name": "account",
"columns": {
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"type": {
"name": "type",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"provider": {
"name": "provider",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"providerAccountId": {
"name": "providerAccountId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"refresh_token": {
"name": "refresh_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"access_token": {
"name": "access_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"expires_at": {
"name": "expires_at",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"token_type": {
"name": "token_type",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"scope": {
"name": "scope",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"id_token": {
"name": "id_token",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"session_state": {
"name": "session_state",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"account_userId_user_id_fk": {
"name": "account_userId_user_id_fk",
"tableFrom": "account",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {
"account_provider_providerAccountId_pk": {
"columns": [
"provider",
"providerAccountId"
],
"name": "account_provider_providerAccountId_pk"
}
},
"uniqueConstraints": {}
},
"apiKey": {
"name": "apiKey",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"createdAt": {
"name": "createdAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"keyId": {
"name": "keyId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"keyHash": {
"name": "keyHash",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"apiKey_keyId_unique": {
"name": "apiKey_keyId_unique",
"columns": [
"keyId"
],
"isUnique": true
},
"apiKey_name_userId_unique": {
"name": "apiKey_name_userId_unique",
"columns": [
"name",
"userId"
],
"isUnique": true
}
},
"foreignKeys": {
"apiKey_userId_user_id_fk": {
"name": "apiKey_userId_user_id_fk",
"tableFrom": "apiKey",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"config": {
"name": "config",
"columns": {
"key": {
"name": "key",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"value": {
"name": "value",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"day": {
"name": "day",
"columns": {
"id": {
"name": "id",
"type": "integer",
"primaryKey": true,
"notNull": true,
"autoincrement": true
},
"mood": {
"name": "mood",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"date": {
"name": "date",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"comment": {
"name": "comment",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"day_date_unique": {
"name": "day_date_unique",
"columns": [
"date"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"label": {
"name": "label",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"createdAt": {
"name": "createdAt",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"code": {
"name": "code",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"description": {
"name": "description",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"color": {
"name": "color",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": "'#000000'"
},
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {
"label_userId_name_unique": {
"name": "label_userId_name_unique",
"columns": [
"userId",
"name"
],
"isUnique": true
}
},
"foreignKeys": {
"label_userId_user_id_fk": {
"name": "label_userId_user_id_fk",
"tableFrom": "label",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"session": {
"name": "session",
"columns": {
"sessionToken": {
"name": "sessionToken",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"userId": {
"name": "userId",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expires": {
"name": "expires",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {
"session_userId_user_id_fk": {
"name": "session_userId_user_id_fk",
"tableFrom": "session",
"tableTo": "user",
"columnsFrom": [
"userId"
],
"columnsTo": [
"id"
],
"onDelete": "cascade",
"onUpdate": "no action"
}
},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"user": {
"name": "user",
"columns": {
"id": {
"name": "id",
"type": "text",
"primaryKey": true,
"notNull": true,
"autoincrement": false
},
"name": {
"name": "name",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"email": {
"name": "email",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"emailVerified": {
"name": "emailVerified",
"type": "integer",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"image": {
"name": "image",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"password": {
"name": "password",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false
},
"role": {
"name": "role",
"type": "text",
"primaryKey": false,
"notNull": false,
"autoincrement": false,
"default": "'user'"
}
},
"indexes": {
"user_email_unique": {
"name": "user_email_unique",
"columns": [
"email"
],
"isUnique": true
}
},
"foreignKeys": {},
"compositePrimaryKeys": {},
"uniqueConstraints": {}
},
"verificationToken": {
"name": "verificationToken",
"columns": {
"identifier": {
"name": "identifier",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"token": {
"name": "token",
"type": "text",
"primaryKey": false,
"notNull": true,
"autoincrement": false
},
"expires": {
"name": "expires",
"type": "integer",
"primaryKey": false,
"notNull": true,
"autoincrement": false
}
},
"indexes": {},
"foreignKeys": {},
"compositePrimaryKeys": {
"verificationToken_identifier_token_pk": {
"columns": [
"identifier",
"token"
],
"name": "verificationToken_identifier_token_pk"
}
},
"uniqueConstraints": {}
}
},
"enums": {},
"_meta": {
"schemas": {},
"tables": {},
"columns": {}
},
"internal": {
"indexes": {}
}
}

View File

@ -5,71 +5,8 @@
{
"idx": 0,
"version": "6",
"when": 1728109876982,
"tag": "0000_worried_may_parker",
"breakpoints": true
},
{
"idx": 1,
"version": "6",
"when": 1731100507972,
"tag": "0001_hard_lionheart",
"breakpoints": true
},
{
"idx": 2,
"version": "6",
"when": 1731542160896,
"tag": "0002_minor_toxin",
"breakpoints": true
},
{
"idx": 3,
"version": "6",
"when": 1731542202120,
"tag": "0003_complex_ares",
"breakpoints": true
},
{
"idx": 4,
"version": "6",
"when": 1731637559763,
"tag": "0004_sad_sally_floyd",
"breakpoints": true
},
{
"idx": 5,
"version": "6",
"when": 1731648881226,
"tag": "0005_ambitious_famine",
"breakpoints": true
},
{
"idx": 6,
"version": "6",
"when": 1731649046343,
"tag": "0006_milky_hellion",
"breakpoints": true
},
{
"idx": 7,
"version": "6",
"when": 1731656341890,
"tag": "0007_unusual_terror",
"breakpoints": true
},
{
"idx": 8,
"version": "6",
"when": 1731660055561,
"tag": "0008_gray_selene",
"breakpoints": true
},
{
"idx": 9,
"version": "6",
"when": 1731660203861,
"tag": "0009_ordinary_electro",
"when": 1732260188078,
"tag": "0000_gigantic_doctor_strange",
"breakpoints": true
}
]

View File

@ -7,6 +7,7 @@
"scripts": {
"dev": "drizzle-kit studio",
"generate": "drizzle-kit generate",
"reset": "tsc reset.ts",
"typecheck": "tsc --noEmit",
"migrate": "tsx migrate.ts",
"studio": "drizzle-kit studio"

27
packages/db/reset.ts Normal file
View File

@ -0,0 +1,27 @@
import { db } from "./drizzle";
import { apiKeys, users } from "./schema";
import { generateApiKey } from "../trpc/auth";
import { and, count, eq } from "drizzle-orm";
db.transaction(async (trx) => {
const ryan = await trx
.insert(users)
.values({
name: "Ryan Pandya",
email: "ryan@ryanpandya.com",
password: "$2a$10$ngv9752uxDT11hSPfdZmAe2D8VXLB9mcXkN7TRPI5GZQCuriIu1gC",
role: "admin",
})
.returning({
id: users.id,
name: users.name,
email: users.email,
role: users.role,
});
db.query.users.findFirst({
where: eq(users.email, "ryan@ryanpandya.com"),
}).then((user) => {
generateApiKey("CLI App", ryan.id);
});
});

View File

@ -1,6 +1,6 @@
import type { AdapterAccount } from "@auth/core/adapters";
import { createId } from "@paralleldrive/cuid2";
import { relations } from "drizzle-orm";
import { relations, SQL, sql } from "drizzle-orm";
import {
AnySQLiteColumn,
index,
@ -9,6 +9,7 @@ import {
sqliteTable,
text,
unique,
} from "drizzle-orm/sqlite-core";
function createdAtField() {
@ -17,6 +18,23 @@ function createdAtField() {
.$defaultFn(() => new Date());
}
export function calcInverseColor(hexcode: string): string {
console.log(hexcode);
const hex = hexcode.replace("#", "");
const r = parseInt(hex.substr(0, 2), 16);
const g = parseInt(hex.substr(2, 2), 16);
const b = parseInt(hex.substr(4, 2), 16);
const luminance = r * 0.299 + g * 0.587 + b * 0.114;
return luminance > 186 ? "#000000" : "#ffffff";
}
export const config = sqliteTable("config", {
key: text("key").notNull().primaryKey(),
value: text("value").notNull(),
});
export const apiKeys = sqliteTable(
"apiKey",
{
@ -105,8 +123,27 @@ export const days = sqliteTable("day", {
comment: text("comment").notNull(),
});
export const labels = sqliteTable(
"label",
export const colors = sqliteTable(
"color",
{
id: text("id")
.notNull()
.primaryKey()
.$defaultFn(() => createId()),
createdAt: createdAtField(),
name: text("name").notNull(),
hexcode: text("hexcode").notNull(),
inverse: text("inverse"),
userId: text("userId")
.notNull()
.references(() => users.id, { onDelete: "cascade" }),
},
(c) => ({
uniq: unique().on(c.userId, c.name)
}),
);
export const categories = sqliteTable(
"category",
{
id: text("id")
.notNull()
@ -116,7 +153,10 @@ export const labels = sqliteTable(
name: text("name").notNull(),
code: integer("code").notNull(),
description: text("description"),
color: text("color").default("#000000"),
colorId: text("colorId")
.notNull()
.references(() => colors.id),
parentId: text("parentId").references(() => categories.id),
userId: text("userId")
.notNull()
.references(() => users.id, { onDelete: "cascade" }),
@ -126,11 +166,6 @@ export const labels = sqliteTable(
}),
);
export const config = sqliteTable("config", {
key: text("key").notNull().primaryKey(),
value: text("value").notNull(),
});
// Relations
export const apiKeyRelations = relations(apiKeys, ({ one }) => ({
@ -140,16 +175,36 @@ export const apiKeyRelations = relations(apiKeys, ({ one }) => ({
}),
}));
export const userRelations = relations(users, ({ many }) => ({
labels: many(labels),
categories: many(categories),
colors: many(colors),
}));
export const labelsRelations = relations(
labels,
export const categoriesRelations = relations(
categories,
({ many, one }) => ({
user: one(users, {
fields: [labels.userId],
fields: [categories.userId],
references: [users.id],
}),
color: one(colors, {
fields: [categories.colorId],
references: [colors.id],
}),
parent: one(categories, {
fields: [categories.parentId],
references: [categories.id],
}),
}),
);
export const colorsRelations = relations(
colors,
({ many, one }) => ({
user: one(users, {
fields: [colors.userId],
references: [users.id],
}),
categories: many(categories),
}),
);

View File

View File

@ -1,25 +1,25 @@
import { z } from "zod";
export const zLabelSchema = z.object({
export const zCategorySchema = z.object({
id: z.string(),
code: z.coerce.number(),
name: z.string(),
color: z.string().default("#000000"),
colorId: z.string(),
description: z.string().optional(),
});
export type ZLabels = z.infer<typeof zLabelSchema>;
export type ZCategories = z.infer<typeof zCategorySchema>;
export const zGetLabelResponseSchema = z.object({
export const zGetCategoryResponseSchema = z.object({
id: z.string(),
code: z.number(),
color: z.string(),
colorId: z.string(),
description: z.string().optional(),
name: z.string(),
numEntries: z.number(),
});
export type ZGetLabelResponse = z.infer<typeof zGetLabelResponseSchema>;
export type ZGetCategoryResponse = z.infer<typeof zGetCategoryResponseSchema>;
export const zUpdateLabelRequestSchema = z.object({
export const zUpdateCategoryRequestSchema = z.object({
labelId: z.string(),
code: z.number(),
name: z.string().optional(),

View File

@ -0,0 +1,7 @@
import { z } from "zod";
export const zColorSchema = z.object({
name: z.string(),
hexcode: z.string(),
});
export type ZColor = z.infer<typeof zColorSchema>;

View File

@ -3,13 +3,15 @@ import { router } from "../index";
import { usersAppRouter } from "./users";
import { apiKeysAppRouter } from "./apiKeys";
import { adminAppRouter } from "./admin";
import { labelsAppRouter } from "./labels";
import { categoriesAppRouter } from "./categories";
import { colorsAppRouter } from "./colors";
export const appRouter = router({
users: usersAppRouter,
apiKeys: apiKeysAppRouter,
admin: adminAppRouter,
labels: labelsAppRouter,
colors: colorsAppRouter,
categories: categoriesAppRouter,
});
// export type definition of API
export type AppRouter = typeof appRouter;

View File

@ -3,32 +3,32 @@ import { and, desc, eq, inArray, notExists } from "drizzle-orm";
import { z } from "zod";
import { SqliteError } from "@lifetracker/db";
import { labels } from "@lifetracker/db/schema";
import { categories } from "@lifetracker/db/schema";
import {
zLabelSchema,
zGetLabelResponseSchema,
zUpdateLabelRequestSchema
} from "@lifetracker/shared/types/labels";
zCategorySchema,
zGetCategoryResponseSchema,
zUpdateCategoryRequestSchema
} from "@lifetracker/shared/types/categories";
import type { Context } from "../index";
import { authedProcedure, router } from "../index";
function conditionFromInput(input: { labelId: string }, userId: string) {
return and(eq(labels.id, input.labelId), eq(labels.userId, userId));
function conditionFromInput(input: { categoryId: string }, userId: string) {
return and(eq(categories.id, input.categoryId), eq(categories.userId, userId));
}
async function createLabel(
input: z.infer<typeof zLabelSchema>,
async function createCategory(
input: z.infer<typeof zCategorySchema>,
ctx: Context,
) {
console.log("Creating a label");
console.log("Creating a category");
return ctx.db.transaction(async (trx) => {
try {
const result = await trx
.insert(labels)
.insert(categories)
.values({
name: input.name,
code: input.code,
@ -37,11 +37,11 @@ async function createLabel(
userId: ctx.user!.id,
})
.returning({
id: labels.id,
name: labels.name,
code: labels.code,
description: labels.description,
color: labels.color,
id: categories.id,
name: categories.name,
code: categories.code,
description: categories.description,
color: categories.color,
});
return result[0];
} catch (e) {
@ -49,7 +49,7 @@ async function createLabel(
if (e.code == "SQLITE_CONSTRAINT_UNIQUE") {
throw new TRPCError({
code: "BAD_REQUEST",
message: "Line 48 trpc routers labels.ts",
message: "Line 48 trpc routers categories.ts",
});
}
}
@ -61,8 +61,8 @@ async function createLabel(
});
}
export const labelsAppRouter = router({
labelStats: authedProcedure
export const categoriesAppRouter = router({
categoryStats: authedProcedure
.output(
z.record(
z.string(),
@ -72,16 +72,16 @@ export const labelsAppRouter = router({
),
)
.query(async ({ ctx }) => {
const [labelIds] = await Promise.all([
ctx.db.select({ id: labels.id }).from(labels)
const [categoryIds] = await Promise.all([
ctx.db.select({ id: categories.id }).from(categories)
]);
const results: Record<
string,
{ numEntries: number }
> = {};
for (const label of labelIds) {
results[label.id] = {
for (const category of categoryIds) {
results[category.id] = {
numEntries: 3330,
};
}
@ -90,50 +90,52 @@ export const labelsAppRouter = router({
list: authedProcedure
.output(
z.object({
labels: z.array(zGetLabelResponseSchema),
categories: z.array(
z.object({
id: z.string(),
name: z.string(),
}),
),
}),
)
.query(async ({ ctx }) => {
const res = await ctx.db
const dbCategories = await ctx.db
.select({
id: labels.id,
name: labels.name,
code: labels.code,
color: labels.color,
description: labels.description,
id: categories.id,
name: categories.name,
})
.from(labels)
.where(eq(labels.userId, ctx.user.id));
.from(categories);
// console.log("Listing cats");
// console.log(dbCategories);
// console.log(dbCategories.map(({ ...category }) => ({
// ...category
// })));
return {
labels: res.map((r) => ({
id: r.id,
name: r.name,
code: r.code,
color: r.color,
description: r.description,
numEntries: 420,
categories: dbCategories.map(({ ...category }) => ({
...category
})),
};
}),
get: authedProcedure
.input(
z.object({
labelId: z.string(),
categoryId: z.string(),
}),
)
.output(zGetLabelResponseSchema)
.output(zGetCategoryResponseSchema)
.query(async ({ input, ctx }) => {
const res = await ctx.db
.select({
id: labels.id,
name: labels.name
id: categories.id,
name: categories.name
})
.from(labels)
.from(categories)
.where(
and(
conditionFromInput(input, ctx.user.id),
eq(labels.userId, ctx.user.id),
eq(categories.userId, ctx.user.id),
),
);
@ -141,12 +143,12 @@ export const labelsAppRouter = router({
throw new TRPCError({ code: "NOT_FOUND" });
}
const numEntriesWithLabel = res.reduce<
Record<ZLabeledByEnum, number>
const numEntriesWithCategory = res.reduce<
Record<ZCategorizedByEnum, number>
>(
(acc, curr) => {
if (curr.labeledBy) {
acc[curr.labeledBy]++;
if (curr.categorizedBy) {
acc[curr.categorizedBy]++;
}
return acc;
},
@ -160,7 +162,7 @@ export const labelsAppRouter = router({
};
}),
create: authedProcedure
.input(zLabelSchema)
.input(zCategorySchema)
.output(
z.object({
id: z.string(),
@ -171,11 +173,11 @@ export const labelsAppRouter = router({
}),
)
.mutation(async ({ input, ctx }) => {
console.log("Just started creating a label");
return createLabel(input, ctx);
console.log("Just started creating a category");
return createCategory(input, ctx);
}),
update: authedProcedure
.input(zUpdateLabelRequestSchema)
.input(zUpdateCategoryRequestSchema)
.output(
z.object({
id: z.string(),
@ -238,7 +240,7 @@ export const labelsAppRouter = router({
delete: authedProcedure
.input(
z.object({
labelId: z.string(),
categoryId: z.string(),
}),
)
.mutation(async ({ input, ctx }) => {
@ -256,7 +258,7 @@ export const labelsAppRouter = router({
// );
const res = await ctx.db
.delete(labels)
.delete(categories)
.where(conditionFromInput(input, ctx.user.id));
if (res.changes == 0) {
throw new TRPCError({ code: "NOT_FOUND" });

View File

@ -0,0 +1,100 @@
import { experimental_trpcMiddleware, TRPCError } from "@trpc/server";
import { and, desc, eq, inArray, notExists } from "drizzle-orm";
import { z } from "zod";
import { SqliteError } from "@lifetracker/db";
import { colors, calcInverseColor } from "@lifetracker/db/schema";
import {
zColorSchema, ZColor
} from "@lifetracker/shared/types/colors";
import type { Context } from "../index";
import { authedProcedure, router } from "../index";
function conditionFromInput(input: { colorId: string }, userId: string) {
return and(eq(colors.id, input.colorId), eq(colors.userId, userId));
}
async function createColor(
input: ZColor,
ctx: Context,
) {
console.log("[TRPC Router] Begin Create Color");
return ctx.db.transaction(async (trx) => {
try {
const result = await trx
.insert(colors)
.values({
name: input.name,
hexcode: input.hexcode,
inverse: calcInverseColor(input.hexcode),
userId: ctx.user!.id,
})
.returning({
id: colors.id,
name: colors.name,
hexcode: colors.hexcode,
});
return result[0];
} catch (e) {
console.log(e);
if (e instanceof SqliteError) {
if (e.code == "SQLITE_CONSTRAINT_UNIQUE") {
throw new TRPCError({
code: "BAD_REQUEST",
message: "This color already exists",
});
}
}
throw new TRPCError({
code: "INTERNAL_SERVER_ERROR",
message: "Something went wrong",
});
}
});
}
export const colorsAppRouter = router({
list: authedProcedure
.output(z.object({
colors: z.array(
z.object({
id: z.string(),
name: z.string(),
hexcode: z.string(),
numCategories: z.number(),
}),
),
}))
.query(async ({ ctx }) => {
const dbColors = await ctx.db
.select({
id: colors.id,
name: colors.name,
hexcode: colors.hexcode,
})
.from(colors);
return {
colors: dbColors.map(({ ...color }) => ({
...color,
numCategories: 0,
})),
};
}),
create: authedProcedure
.input(zColorSchema)
.output(
z.object({
id: z.string(),
hexcode: z.string(),
name: z.string(),
}),
)
.mutation(async ({ input, ctx }) => {
return createColor(input, ctx);
}),
});

62
pnpm-lock.yaml generated
View File

@ -26,6 +26,12 @@ importers:
'@lifetracker/trpc':
specifier: workspace:^
version: link:../../packages/trpc
dotenv:
specifier: ^16.4.1
version: 16.4.5
table:
specifier: ^6.8.2
version: 6.8.2
vite-tsconfig-paths:
specifier: ^5.1.0
version: 5.1.0(typescript@5.6.3)(vite@5.4.10(@types/node@20.11.24)(lightningcss@1.28.1)(terser@5.34.1))
@ -223,6 +229,9 @@ importers:
clsx:
specifier: ^2.1.0
version: 2.1.1
color-2-name:
specifier: ^1.4.4
version: 1.4.4
csv-parse:
specifier: ^5.5.6
version: 5.5.6
@ -304,6 +313,9 @@ importers:
tailwind-merge:
specifier: ^2.2.1
version: 2.5.4
title-case:
specifier: ^4.3.2
version: 4.3.2
zod:
specifier: ^3.22.4
version: 3.23.8
@ -4743,6 +4755,10 @@ packages:
resolution: {integrity: sha512-c27loCv9QkZinsa5ProX751khO9DJl/AcB5c2KNtA6NRvHKS0PgLfcftz72KVq504vB0Gku5s2kUZzDBvQWvHg==}
engines: {node: '>=4'}
astral-regex@2.0.0:
resolution: {integrity: sha512-Z7tMw1ytTXt5jqMcOP+OQteU1VuNK9Y02uuJtKQ1Sv69jXQKKg5cibLwGJow8yzZP+eAc18EmLGPal0bp36rvQ==}
engines: {node: '>=8'}
astring@1.9.0:
resolution: {integrity: sha512-LElXdjswlqjWrPpJFg1Fx4wpkOCxj1TDHlSV4PlaRxHGWko024xICaa97ZkMfs6DRKlCguiAI+rbXv5GWwXIkg==}
hasBin: true
@ -5294,6 +5310,10 @@ packages:
collapse-white-space@2.1.0:
resolution: {integrity: sha512-loKTxY1zCOuG4j9f6EPnuyyYkf58RnhhWTvRoZEokgB+WbdXehfjFviyOVYkqzEWz1Q5kRiZdBYS5SwxbQYwzw==}
color-2-name@1.4.4:
resolution: {integrity: sha512-CSF+PANU5YSZYviiU88GJBeJADD4g9mydxLRMYtMEqVxhcLyl72b6PkMQnvomZyUZZLbPhfXs42QZcR0We4JOA==}
engines: {node: '>=14.0.0', npm: '>=6.0.0'}
color-convert@1.9.3:
resolution: {integrity: sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==}
@ -8095,6 +8115,9 @@ packages:
lodash.throttle@4.1.1:
resolution: {integrity: sha512-wIkUCfVKpVsWo3JSZlc+8MB5it+2AN5W8J7YVMST30UrvcQNZ1Okbj+rbVniijTWE6FGYy4XJq/rHkas8qJMLQ==}
lodash.truncate@4.4.2:
resolution: {integrity: sha512-jttmRe7bRse52OsWIMDLaXxWqRAmtIUccAQ3garviCqJjafXOfNMO0yMfNpdD6zbGaTU0P5Nz7e7gAT6cKmJRw==}
lodash.uniq@4.5.0:
resolution: {integrity: sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==}
@ -10438,6 +10461,10 @@ packages:
resolution: {integrity: sha512-3dOsAHXXUkQTpOYcoAxLIorMTp4gIQr5IW3iVb7A7lFIp0VHhnynm9izx6TssdrIcVIESAlVjtnO2K8bg+Coew==}
engines: {node: '>=12'}
slice-ansi@4.0.0:
resolution: {integrity: sha512-qMCMfhY040cVHT43K9BFygqYbUPFZKHOg7K73mtTWJRb8pyP3fzf4Ixd5SzdEJQ6MRUg/WBnOLxghZtKKurENQ==}
engines: {node: '>=10'}
slugify@1.6.6:
resolution: {integrity: sha512-h+z7HKHYXj6wJU+AnS/+IH8Uh9fdcX1Lrhg1/VMdf9PwoBQXFcXiAdsy2tSK0P6gKwJLXp02r90ahUCqHk9rrw==}
engines: {node: '>=8.0.0'}
@ -10764,6 +10791,10 @@ packages:
resolution: {integrity: sha512-L1dapNV6vu2s/4Sputv8xGsCdAVlb5nRDMFU/E27D44l5U6cw1g0dGd45uLc+OXjNMmF4ntiMdCimzcjFKQI8Q==}
engines: {node: ^14.18.0 || >=16.0.0}
table@6.8.2:
resolution: {integrity: sha512-w2sfv80nrAh2VCbqR5AK27wswXhqcck2AhfnNW76beQXskGZ1V12GwS//yYVa3d3fcvAip2OUnbDAjW2k3v9fA==}
engines: {node: '>=10.0.0'}
tailwind-merge@2.5.4:
resolution: {integrity: sha512-0q8cfZHMu9nuYP/b5Shb7Y7Sh1B7Nnl5GqNr1U+n2p6+mybvRtayrQ+0042Z5byvTA8ihjlP8Odo8/VnHbZu4Q==}
@ -10918,6 +10949,9 @@ packages:
title-case@2.1.1:
resolution: {integrity: sha512-EkJoZ2O3zdCz3zJsYCsxyq2OC5hrxR9mfdd5I+w8h/tmFfeOxJ+vvkxsKxdmN0WtS9zLdHEgfgVOiMVgv+Po4Q==}
title-case@4.3.2:
resolution: {integrity: sha512-I/nkcBo73mO42Idfv08jhInV61IMb61OdIFxk+B4Gu1oBjWBPOLmhZdsli+oJCVaD+86pYQA93cJfFt224ZFAA==}
titleize@3.0.0:
resolution: {integrity: sha512-KxVu8EYHDPBdUYdKZdKtU2aj2XfEx9AfjXxE/Aj0vT06w2icA09Vus1rh6eSu1y01akYg6BjIK/hxyLJINoMLQ==}
engines: {node: '>=12'}
@ -17893,6 +17927,8 @@ snapshots:
dependencies:
tslib: 2.8.1
astral-regex@2.0.0: {}
astring@1.9.0: {}
async-limiter@1.0.1: {}
@ -18613,6 +18649,8 @@ snapshots:
collapse-white-space@2.1.0: {}
color-2-name@1.4.4: {}
color-convert@1.9.3:
dependencies:
color-name: 1.1.3
@ -19693,7 +19731,7 @@ snapshots:
eslint: 8.57.0
eslint-import-resolver-node: 0.3.9
eslint-import-resolver-typescript: 3.6.1(@typescript-eslint/parser@7.1.0(eslint@8.57.0)(typescript@5.3.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.0(eslint@8.57.0))(eslint@8.57.0)
eslint-plugin-import: 2.29.0(@typescript-eslint/parser@7.1.0(eslint@8.57.0)(typescript@5.3.3))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0)
eslint-plugin-import: 2.29.0(@typescript-eslint/parser@7.1.0(eslint@8.57.0)(typescript@5.3.3))(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.1.0(eslint@8.57.0)(typescript@5.3.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.0(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0)
eslint-plugin-jsx-a11y: 6.8.0(eslint@8.57.0)
eslint-plugin-react: 7.33.2(eslint@8.57.0)
eslint-plugin-react-hooks: 4.6.0(eslint@8.57.0)
@ -19747,7 +19785,7 @@ snapshots:
enhanced-resolve: 5.15.0
eslint: 8.57.0
eslint-module-utils: 2.8.0(@typescript-eslint/parser@7.1.0(eslint@8.57.0)(typescript@5.3.3))(eslint-import-resolver-node@0.3.9)(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.1.0(eslint@8.57.0)(typescript@5.3.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.0(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0)
eslint-plugin-import: 2.29.0(@typescript-eslint/parser@7.1.0(eslint@8.57.0)(typescript@5.3.3))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0)
eslint-plugin-import: 2.29.0(@typescript-eslint/parser@7.1.0(eslint@8.57.0)(typescript@5.3.3))(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.1.0(eslint@8.57.0)(typescript@5.3.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.0(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0)
fast-glob: 3.3.1
get-tsconfig: 4.7.2
is-core-module: 2.13.1
@ -19786,7 +19824,7 @@ snapshots:
eslint: 8.57.0
ignore: 5.3.1
eslint-plugin-import@2.29.0(@typescript-eslint/parser@7.1.0(eslint@8.57.0)(typescript@5.3.3))(eslint-import-resolver-typescript@3.6.1)(eslint@8.57.0):
eslint-plugin-import@2.29.0(@typescript-eslint/parser@7.1.0(eslint@8.57.0)(typescript@5.3.3))(eslint-import-resolver-typescript@3.6.1(@typescript-eslint/parser@7.1.0(eslint@8.57.0)(typescript@5.3.3))(eslint-import-resolver-node@0.3.9)(eslint-plugin-import@2.29.0(eslint@8.57.0))(eslint@8.57.0))(eslint@8.57.0):
dependencies:
array-includes: 3.1.7
array.prototype.findlastindex: 1.2.3
@ -21944,6 +21982,8 @@ snapshots:
lodash.throttle@4.1.1: {}
lodash.truncate@4.4.2: {}
lodash.uniq@4.5.0: {}
lodash@4.17.21: {}
@ -25122,6 +25162,12 @@ snapshots:
slash@4.0.0: {}
slice-ansi@4.0.0:
dependencies:
ansi-styles: 4.3.0
astral-regex: 2.0.0
is-fullwidth-code-point: 3.0.0
slugify@1.6.6: {}
smart-buffer@4.2.0: {}
@ -25482,6 +25528,14 @@ snapshots:
'@pkgr/utils': 2.4.2
tslib: 2.6.2
table@6.8.2:
dependencies:
ajv: 8.17.1
lodash.truncate: 4.4.2
slice-ansi: 4.0.0
string-width: 4.2.3
strip-ansi: 6.0.1
tailwind-merge@2.5.4: {}
tailwindcss-animate@1.0.7(tailwindcss@3.4.15(ts-node@10.9.1(@types/node@20.11.24)(typescript@5.6.3))):
@ -25654,6 +25708,8 @@ snapshots:
no-case: 2.3.2
upper-case: 1.1.3
title-case@4.3.2: {}
titleize@3.0.0: {}
tmp@0.0.33: