Skip to content

Commit

Permalink
remove managers, set asset type to txt over autoincrement int
Browse files Browse the repository at this point in the history
  • Loading branch information
dromzeh committed Mar 17, 2024
1 parent 96ba39b commit 090856c
Show file tree
Hide file tree
Showing 24 changed files with 107 additions and 1,364 deletions.
6 changes: 0 additions & 6 deletions src/scripts/seed/seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ async function main() {
.insert(asset)
.values([
{
id: 1,
name: "test-asset",
extension: "image/png",
gameId: "genshin-impact",
Expand All @@ -276,7 +275,6 @@ async function main() {
height: 512,
},
{
id: 2,
name: "test-asset-2",
extension: "image/png",
gameId: "honkai-impact-3rd",
Expand All @@ -292,7 +290,6 @@ async function main() {
height: 1080,
},
{
id: 3,
name: "test-asset-3",
extension: "image/png",
gameId: "genshin-impact",
Expand All @@ -308,7 +305,6 @@ async function main() {
height: 1920,
},
{
id: 4,
name: "test-asset-4",
extension: "image/png",
gameId: "genshin-impact",
Expand All @@ -324,7 +320,6 @@ async function main() {
height: 1080,
},
{
id: 5,
name: "test-asset-5",
extension: "image/png",
gameId: "genshin-impact",
Expand All @@ -337,7 +332,6 @@ async function main() {
downloadCount: 1337,
},
{
id: 6,
name: "test-asset-6",
extension: "image/png",
gameId: "honkai-impact-3rd",
Expand Down
2 changes: 1 addition & 1 deletion src/v2/db/schema/asset/asset-comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const assetComments = sqliteTable(
.$defaultFn(() => {
return generateID()
}),
assetId: integer("asset_id").references(() => asset.id, {
assetId: text("asset_id").references(() => asset.id, {
onUpdate: "cascade",
onDelete: "cascade",
}),
Expand Down
2 changes: 1 addition & 1 deletion src/v2/db/schema/asset/asset-likes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { createInsertSchema, createSelectSchema } from "drizzle-zod"
export const assetLikes = sqliteTable(
tableNames.assetLikes,
{
assetId: integer("asset_id")
assetId: text("asset_id")
.notNull()
.references(() => asset.id, {
onUpdate: "cascade",
Expand Down
8 changes: 7 additions & 1 deletion src/v2/db/schema/asset/asset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { createInsertSchema, createSelectSchema } from "drizzle-zod"
import { assetLikes } from "./asset-likes"
import { assetExternalFile } from "./asset-external-files"
import { assetComments } from "./asset-comments"
import { generateID } from "@/v2/lib/oslo"

/*
NOTE: Assets have a lot of relations, and can be quite complex in some cases.
Expand All @@ -31,7 +32,12 @@ export type AssetStatus = "pending" | "approved" | "rejected"
export const asset = sqliteTable(
tableNames.asset,
{
id: integer("id").primaryKey(), // primary key auto increments on sqlite
id: text("id")
.primaryKey()
.notNull()
.$defaultFn(() => {
return generateID()
}),
name: text("name").notNull(),
extension: text("extension").notNull(),
gameId: text("game")
Expand Down
2 changes: 1 addition & 1 deletion src/v2/db/schema/collections/user-collections.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const userCollectionAsset = sqliteTable(
onUpdate: "cascade",
onDelete: "cascade",
}),
assetId: integer("asset_id")
assetId: text("asset_id")
.notNull()
.references(() => asset.id, {
onUpdate: "cascade",
Expand Down
2 changes: 1 addition & 1 deletion src/v2/db/schema/tags/asset-tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export const assetTagAsset = sqliteTable(
onUpdate: "cascade",
onDelete: "cascade",
}),
assetId: integer("asset_id")
assetId: text("asset_id")
.notNull()
.references(() => asset.id, {
onUpdate: "cascade",
Expand Down
2 changes: 1 addition & 1 deletion src/v2/db/schema/user/user-favourites.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const userFavouriteAsset = sqliteTable(
onUpdate: "cascade",
onDelete: "cascade",
}),
assetId: integer("asset_id")
assetId: text("asset_id")
.notNull()
.references(() => asset.id, {
onUpdate: "cascade",
Expand Down
61 changes: 0 additions & 61 deletions src/v2/lib/managers/asset-category/asset-category-likes.ts

This file was deleted.

169 changes: 0 additions & 169 deletions src/v2/lib/managers/asset-category/asset-category-manager.ts

This file was deleted.

Loading

0 comments on commit 090856c

Please sign in to comment.