Hussein
Hussein
Explore posts from servers
DTDrizzle Team
Created by Hussein on 10/26/2023 in #help
"Seems like the schema generic is missing - did you forget to add it to your DB type?"
DrizzleError: Failed to run the query 'CREATE TABLE `follows` (
`id` text(128) PRIMARY KEY NOT NULL,
PRIMARY KEY(`id`, `id`)
);
': table "follows" has more than one primary key
DrizzleError: Failed to run the query 'CREATE TABLE `follows` (
`id` text(128) PRIMARY KEY NOT NULL,
PRIMARY KEY(`id`, `id`)
);
': table "follows" has more than one primary key
19 replies
DTDrizzle Team
Created by Hussein on 10/26/2023 in #help
"Seems like the schema generic is missing - did you forget to add it to your DB type?"
can you help me with this schema
19 replies
DTDrizzle Team
Created by Hussein on 10/26/2023 in #help
"Seems like the schema generic is missing - did you forget to add it to your DB type?"
thanks
19 replies
DTDrizzle Team
Created by Hussein on 10/26/2023 in #help
"Seems like the schema generic is missing - did you forget to add it to your DB type?"
import {primaryKey, sqliteTable, text} from 'drizzle-orm/sqlite-core'
import {createId} from '@paralleldrive/cuid2'
import {relations} from 'drizzle-orm'

const id = text('id', {length: 128})
.primaryKey()
.$defaultFn(() => createId())

export const users = sqliteTable('users', {
id,
username: text('username', {length: 255}).unique().notNull(),
password: text('password', {length: 255}).notNull(),
profilePicture: text('profile_picture'),
profilePictureAlt: text('pfp_alt')
})

export const usersRelations = relations(users, ({many}) => ({
follows: many(follows, {relationName: 'follows'}),
followers: many(follows, {relationName: 'followers'})
}))

export const follows = sqliteTable(
'follows',
{
followerId: id,
followeeId: id
},
(t) => ({
pk: primaryKey(t.followerId, t.followeeId)
})
)

export const followsRelations = relations(follows, ({one}) => ({
follower: one(users, {
fields: [follows.followerId],
references: [users.id],
relationName: 'follows'
}),
followee: one(users, {
fields: [follows.followeeId],
references: [users.id],
relationName: 'followers'
})
}))
import {primaryKey, sqliteTable, text} from 'drizzle-orm/sqlite-core'
import {createId} from '@paralleldrive/cuid2'
import {relations} from 'drizzle-orm'

const id = text('id', {length: 128})
.primaryKey()
.$defaultFn(() => createId())

export const users = sqliteTable('users', {
id,
username: text('username', {length: 255}).unique().notNull(),
password: text('password', {length: 255}).notNull(),
profilePicture: text('profile_picture'),
profilePictureAlt: text('pfp_alt')
})

export const usersRelations = relations(users, ({many}) => ({
follows: many(follows, {relationName: 'follows'}),
followers: many(follows, {relationName: 'followers'})
}))

export const follows = sqliteTable(
'follows',
{
followerId: id,
followeeId: id
},
(t) => ({
pk: primaryKey(t.followerId, t.followeeId)
})
)

export const followsRelations = relations(follows, ({one}) => ({
follower: one(users, {
fields: [follows.followerId],
references: [users.id],
relationName: 'follows'
}),
followee: one(users, {
fields: [follows.followeeId],
references: [users.id],
relationName: 'followers'
})
}))
19 replies
DTDrizzle Team
Created by Hussein on 10/26/2023 in #help
"Seems like the schema generic is missing - did you forget to add it to your DB type?"
so now its
19 replies
DTDrizzle Team
Created by Hussein on 10/26/2023 in #help
"Seems like the schema generic is missing - did you forget to add it to your DB type?"
19 replies
DTDrizzle Team
Created by Hussein on 10/26/2023 in #help
"Seems like the schema generic is missing - did you forget to add it to your DB type?"
import * as schema from '../../schema'
import Database from 'better-sqlite3'
import {migrate} from 'drizzle-orm/better-sqlite3/migrator'
import {drizzle, type BetterSQLite3Database} from 'drizzle-orm/better-sqlite3'

const sqlite = new Database('sqlite.db')
export const database: BetterSQLite3Database = drizzle(sqlite, {schema})
import * as schema from '../../schema'
import Database from 'better-sqlite3'
import {migrate} from 'drizzle-orm/better-sqlite3/migrator'
import {drizzle, type BetterSQLite3Database} from 'drizzle-orm/better-sqlite3'

const sqlite = new Database('sqlite.db')
export const database: BetterSQLite3Database = drizzle(sqlite, {schema})
19 replies
DTDrizzle Team
Created by Hussein on 10/26/2023 in #help
"Seems like the schema generic is missing - did you forget to add it to your DB type?"
import {sqliteTable, text} from 'drizzle-orm/sqlite-core'
import {createId} from '@paralleldrive/cuid2'
import {relations} from 'drizzle-orm'

const id = text('id', {length: 128})
.primaryKey()
.$defaultFn(() => createId())

export const users = sqliteTable('users', {
id,
username: text('username', {length: 255}).unique().notNull(),
password: text('password', {length: 255}).notNull(),
profilePicture: text('profile_picture'),
profilePictureAlt: text('pfp_alt')
})

export const usersRelations = relations(users, ({many}) => ({
posts: many(friends)
}))

export const friends = sqliteTable('posts', {
userId: text('user_id'),
friendId: text('friend_id')
})

export const friendsRelations = relations(friends, ({one}) => ({
user: one(users, {
fields: [friends.userId, friends.friendId],
references: [users.id, users.id]
})
}))
import {sqliteTable, text} from 'drizzle-orm/sqlite-core'
import {createId} from '@paralleldrive/cuid2'
import {relations} from 'drizzle-orm'

const id = text('id', {length: 128})
.primaryKey()
.$defaultFn(() => createId())

export const users = sqliteTable('users', {
id,
username: text('username', {length: 255}).unique().notNull(),
password: text('password', {length: 255}).notNull(),
profilePicture: text('profile_picture'),
profilePictureAlt: text('pfp_alt')
})

export const usersRelations = relations(users, ({many}) => ({
posts: many(friends)
}))

export const friends = sqliteTable('posts', {
userId: text('user_id'),
friendId: text('friend_id')
})

export const friendsRelations = relations(friends, ({one}) => ({
user: one(users, {
fields: [friends.userId, friends.friendId],
references: [users.id, users.id]
})
}))
19 replies
DTDrizzle Team
Created by Hussein on 10/26/2023 in #help
"Seems like the schema generic is missing - did you forget to add it to your DB type?"
this is my schema
19 replies
DTDrizzle Team
Created by Hussein on 10/26/2023 in #help
"Seems like the schema generic is missing - did you forget to add it to your DB type?"
Type 'BetterSQLite3Database<typeof import("/home/h/Desktop/web-app/src/schema")>' is not assignable to type 'BetterSQLite3Database'.
The types of '_.schema' are incompatible between these types.
Type 'ExtractTablesWithRelations<typeof import("/home/h/Desktop/web-app/src/schema")> | undefined' is not assignable to type 'ExtractTablesWithRelations<Record<string, never>> | undefined'.
Type 'ExtractTablesWithRelations<typeof import("/home/h/Desktop/web-app/src/schema")>' is not assignable to type 'ExtractTablesWithRelations<Record<string, never>>'.
Property 'users' is incompatible with index signature.
Type '{ tsName: "users"; dbName: "users"; columns: { id: SQLiteColumn<{ name: "id"; tableName: "users"; dataType: "string"; columnType: "SQLiteText"; data: string; driverParam: string; notNull: true; hasDefault: true; enumValues: [...]; baseColumn: never; }, object>; username: SQLiteColumn<...>; password: SQLiteColumn<......' is not assignable to type '{ tsName: string; dbName: never; columns: never; relations: Record<string, Relation<string>>; primaryKey: AnyColumn[]; }'.
Types of property 'dbName' are incompatible.
Type 'string' is not assignable to type 'never'.ts(2322)
Type 'BetterSQLite3Database<typeof import("/home/h/Desktop/web-app/src/schema")>' is not assignable to type 'BetterSQLite3Database'.
The types of '_.schema' are incompatible between these types.
Type 'ExtractTablesWithRelations<typeof import("/home/h/Desktop/web-app/src/schema")> | undefined' is not assignable to type 'ExtractTablesWithRelations<Record<string, never>> | undefined'.
Type 'ExtractTablesWithRelations<typeof import("/home/h/Desktop/web-app/src/schema")>' is not assignable to type 'ExtractTablesWithRelations<Record<string, never>>'.
Property 'users' is incompatible with index signature.
Type '{ tsName: "users"; dbName: "users"; columns: { id: SQLiteColumn<{ name: "id"; tableName: "users"; dataType: "string"; columnType: "SQLiteText"; data: string; driverParam: string; notNull: true; hasDefault: true; enumValues: [...]; baseColumn: never; }, object>; username: SQLiteColumn<...>; password: SQLiteColumn<......' is not assignable to type '{ tsName: string; dbName: never; columns: never; relations: Record<string, Relation<string>>; primaryKey: AnyColumn[]; }'.
Types of property 'dbName' are incompatible.
Type 'string' is not assignable to type 'never'.ts(2322)
19 replies
DTDrizzle Team
Created by Hussein on 10/26/2023 in #help
"Seems like the schema generic is missing - did you forget to add it to your DB type?"
its giving me this huge error
19 replies
DTDrizzle Team
Created by Hussein on 10/26/2023 in #help
"Seems like the schema generic is missing - did you forget to add it to your DB type?"
do i need to pass {schema} to drizzle()?
19 replies
DTDrizzle Team
Created by Hussein on 10/26/2023 in #help
"Seems like the schema generic is missing - did you forget to add it to your DB type?"
?
19 replies