SPS | Shootmail
SPS | Shootmail
Explore posts from servers
DTDrizzle Team
Created by SPS | Shootmail on 9/20/2023 in #help
push:sqlite creating weird tables
Alright, will try this.
8 replies
DTDrizzle Team
Created by SPS | Shootmail on 9/20/2023 in #help
push:sqlite creating weird tables
You are saying if i use migrations, i will not have these problems?
8 replies
DTDrizzle Team
Created by SPS | Shootmail on 9/20/2023 in #help
push:sqlite creating weird tables
Should I use migrations instead to avoid these problems?
8 replies
DTDrizzle Team
Created by SPS | Shootmail on 9/20/2023 in #help
push:sqlite creating weird tables
This is creating a lot of problems lately. Every time I do a push, it fails because of these tables.
8 replies
DTDrizzle Team
Created by SPS | Shootmail on 9/20/2023 in #help
push:sqlite creating weird tables
For almost every insert now tables are referncing these __old tables
proto: {
message: 'SQLite error: no such table: main.__old_push_media',
code: 'SQLITE_UNKNOWN'
}
proto: {
message: 'SQLite error: no such table: main.__old_push_media',
code: 'SQLITE_UNKNOWN'
}
8 replies
DTDrizzle Team
Created by thdxr on 7/17/2023 in #help
Cannot read properties of undefined (reading 'columns')
Thanks
32 replies
DTDrizzle Team
Created by thdxr on 7/17/2023 in #help
Cannot read properties of undefined (reading 'columns')
Hey @Andrew Sherman were you able to check this?
32 replies
DTDrizzle Team
Created by thdxr on 7/17/2023 in #help
Cannot read properties of undefined (reading 'columns')
Sure
32 replies
DTDrizzle Team
Created by thdxr on 7/17/2023 in #help
Cannot read properties of undefined (reading 'columns')
But didn't work with the remote db that already had tables and data
32 replies
DTDrizzle Team
Created by thdxr on 7/17/2023 in #help
Cannot read properties of undefined (reading 'columns')
I was trying push:sqlite against remote turso db database. Then I tried with a fresh local turso db and it worked.
32 replies
DTDrizzle Team
Created by thdxr on 7/17/2023 in #help
Cannot read properties of undefined (reading 'columns')
export const users = sqliteTable("users", {
id: text("id").unique().notNull(),
email: text('email').notNull(),
createdAt: integer('created_at', { mode: 'timestamp' }).default(sql`(strftime('%s', 'now'))`),
status: text('status', {enum: ["ACTIVE", "INACTIVE"]}).default("INACTIVE"),
organizationId: text("organization_id")
}, (users) => ({
emailIdx: index("user_email_idx").on(users.email),
emailOrgPrimaryKey: primaryKey(users.email, users.organizationId)
}));
export const users = sqliteTable("users", {
id: text("id").unique().notNull(),
email: text('email').notNull(),
createdAt: integer('created_at', { mode: 'timestamp' }).default(sql`(strftime('%s', 'now'))`),
status: text('status', {enum: ["ACTIVE", "INACTIVE"]}).default("INACTIVE"),
organizationId: text("organization_id")
}, (users) => ({
emailIdx: index("user_email_idx").on(users.email),
emailOrgPrimaryKey: primaryKey(users.email, users.organizationId)
}));
32 replies
DTDrizzle Team
Created by thdxr on 7/17/2023 in #help
Cannot read properties of undefined (reading 'columns')
1. Added these two tables:
export const session = sqliteTable("user_session", {
id: text("id").primaryKey(),
userId: text("user_id")
.notNull()
.references(() => users.id),
activeExpires: blob("active_expires", {
mode: "bigint"
}).notNull(),
idleExpires: blob("idle_expires", {
mode: "bigint"
}).notNull()
});

export const key = sqliteTable("user_key", {
id: text("id").primaryKey(),
userId: text("user_id")
.notNull()
.references(() => users.id),
hashedPassword: text("hashed_password")
});
export const session = sqliteTable("user_session", {
id: text("id").primaryKey(),
userId: text("user_id")
.notNull()
.references(() => users.id),
activeExpires: blob("active_expires", {
mode: "bigint"
}).notNull(),
idleExpires: blob("idle_expires", {
mode: "bigint"
}).notNull()
});

export const key = sqliteTable("user_key", {
id: text("id").primaryKey(),
userId: text("user_id")
.notNull()
.references(() => users.id),
hashedPassword: text("hashed_password")
});
2. Removed a table named auth_key 3. In the users table earlier only the id was primaryKey, now I have changed it to a composite key of id, organizationId
32 replies
DTDrizzle Team
Created by thdxr on 7/17/2023 in #help
Cannot read properties of undefined (reading 'columns')
*push:sqlite
32 replies
DTDrizzle Team
Created by thdxr on 7/17/2023 in #help
Cannot read properties of undefined (reading 'columns')
TypeError: Cannot read properties of undefined (reading 'columns')
at _moveDataStatements (/Users/subhendusingh/Documents/storebud/storebud-mono/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:52617:61)
at logSuggestionsAndReturn2 (/Users/subhendusingh/Documents/storebud/storebud-mono/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:52842:39)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Command.<anonymous> (/Users/subhendusingh/Documents/storebud/storebud-mono/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:53456:11)
TypeError: Cannot read properties of undefined (reading 'columns')
at _moveDataStatements (/Users/subhendusingh/Documents/storebud/storebud-mono/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:52617:61)
at logSuggestionsAndReturn2 (/Users/subhendusingh/Documents/storebud/storebud-mono/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:52842:39)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Command.<anonymous> (/Users/subhendusingh/Documents/storebud/storebud-mono/node_modules/.pnpm/[email protected]/node_modules/drizzle-kit/index.cjs:53456:11)
Getting this in 0.19.13 with sqlite:push
32 replies
DTDrizzle Team
Created by SPS | Shootmail on 6/29/2023 in #help
Can't figure out how to design relational query
Sorry i am on phone so couldn't format correctly
9 replies
DTDrizzle Team
Created by SPS | Shootmail on 6/29/2023 in #help
Can't figure out how to design relational query
Here is what i ended up doing
const countQuery = await db.select({ count: sql<number>`count(*)`, categoryId: categories.id }).from(products)
.innerJoin(categories, eq(categories.id, products.categoryId))
.where(and(eq(categories.isVisible, 1), eq(categories.slug, slug),eq(products.isVisible, 1), eq(categories.organizationId, orgId))).get();

if(!countQuery){
return err(ServiceClientException("Error ocurred while retrieving the total product count for category" + slug, c));
}

const productsQuery = db.query.products.findMany({
with: {
category: true,
mediaOnProducts: {
with: { media: true }
}
},
where: (products, { and, eq}) => and(eq(products.isVisible, 1), eq(products.organizationId, orgId), eq(products.categoryId, countQuery.categoryId)),
offset: offset,
limit: limit
});
const countQuery = await db.select({ count: sql<number>`count(*)`, categoryId: categories.id }).from(products)
.innerJoin(categories, eq(categories.id, products.categoryId))
.where(and(eq(categories.isVisible, 1), eq(categories.slug, slug),eq(products.isVisible, 1), eq(categories.organizationId, orgId))).get();

if(!countQuery){
return err(ServiceClientException("Error ocurred while retrieving the total product count for category" + slug, c));
}

const productsQuery = db.query.products.findMany({
with: {
category: true,
mediaOnProducts: {
with: { media: true }
}
},
where: (products, { and, eq}) => and(eq(products.isVisible, 1), eq(products.organizationId, orgId), eq(products.categoryId, countQuery.categoryId)),
offset: offset,
limit: limit
});
9 replies
DTDrizzle Team
Created by SPS | Shootmail on 7/1/2023 in #help
Modelling self relations
Got it relationName is what I needed, it's not documented though
export const categoryProductsRelation = relations(categories, ({ many, one })=>({
productsOnCategory: many(products),
subcategories: many(categories, {relationName: "subcategories"}),
parentCategory: one(categories, {
fields: [categories.parent],
references: [categories.id],
relationName: "subcategories"
})
}));
export const categoryProductsRelation = relations(categories, ({ many, one })=>({
productsOnCategory: many(products),
subcategories: many(categories, {relationName: "subcategories"}),
parentCategory: one(categories, {
fields: [categories.parent],
references: [categories.id],
relationName: "subcategories"
})
}));
10 replies
DTDrizzle Team
Created by SPS | Shootmail on 7/1/2023 in #help
Modelling self relations
I want to retrieve a category along with its parent and sub-categories.
10 replies
DTDrizzle Team
Created by SPS | Shootmail on 6/29/2023 in #help
Can't figure out how to design relational query
Got it, that's what I ended up doing. Thanks!
9 replies
DTDrizzle Team
Created by SPS | Shootmail on 6/29/2023 in #help
Can't figure out how to design relational query
In this case, I will arrive at problem no 2 I have mentioned above. I can set the value for limit and offset but i cannot set filter for category slug.
9 replies