RaSk
RaSk
DTDrizzle Team
Created by RaSk on 6/1/2024 in #help
rollback() not implemented for sqlite-core?
Nevermind I guess this is "normal" Implemented a try/catch with error instaceof TransactionRollbackError
5 replies
DTDrizzle Team
Created by RaSk on 6/1/2024 in #help
rollback() not implemented for sqlite-core?
or is it normal to throw errors on rollback?
5 replies
DTDrizzle Team
Created by RaSk on 6/1/2024 in #help
rollback() not implemented for sqlite-core?
// TODO: support transaction behavior in libsql/session (link) 😅
5 replies
DTDrizzle Team
Created by RaSk on 6/1/2024 in #help
rollback() not implemented for sqlite-core?
Context: Using turso + libsql-ts + drizzle-orm (versions below) Relevant callstack:
TransactionRollbackError [DrizzleError]: Rollback
at LibSQLTransaction.rollback (<redacted>/[email protected]_@[email protected]_@[email protected][email protected]/node_modules/drizzle-orm/sqlite-core/session.js:109:11)
<redacted>
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async LibSQLSession.transaction (<redacted>/[email protected]_@[email protected]_@[email protected][email protected]/node_modules/drizzle-orm/libsql/session.js:53:22)
TransactionRollbackError [DrizzleError]: Rollback
at LibSQLTransaction.rollback (<redacted>/[email protected]_@[email protected]_@[email protected][email protected]/node_modules/drizzle-orm/sqlite-core/session.js:109:11)
<redacted>
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async LibSQLSession.transaction (<redacted>/[email protected]_@[email protected]_@[email protected][email protected]/node_modules/drizzle-orm/libsql/session.js:53:22)
5 replies
DTDrizzle Team
Created by RaSk on 5/11/2024 in #help
drizzle-kit push from JS
async function main() {
// Wiping database
const pathToDb = join(import.meta.dirname, "local.db");
await access(pathToDb);
await unlink(pathToDb);
await writeFile(pathToDb, "");

// Applying schema
const { db } = await import("./db");
await migrate(db, {
migrationsFolder: join(import.meta.dirname, "migrations"),
});
};
async function main() {
// Wiping database
const pathToDb = join(import.meta.dirname, "local.db");
await access(pathToDb);
await unlink(pathToDb);
await writeFile(pathToDb, "");

// Applying schema
const { db } = await import("./db");
await migrate(db, {
migrationsFolder: join(import.meta.dirname, "migrations"),
});
};
not my best code but it works 😄
7 replies
DTDrizzle Team
Created by RaSk on 5/11/2024 in #help
drizzle-kit push from JS
nevermind, it's reading JSON, it's not an issue 😅
7 replies
DTDrizzle Team
Created by RaSk on 5/11/2024 in #help
drizzle-kit push from JS
Should I open an issue for this? Lemme try first if it works even if TS is not happy
7 replies
DTDrizzle Team
Created by RaSk on 5/11/2024 in #help
drizzle-kit push from JS
/**
@file drizzle-orm/migrator.d.ts
This is the first call of the function migrate() from libsql export
*/
readMigrationFiles(config: string | MigrationConfig): MigrationMeta[];
// here accepts both types

/** @file drizzle-orm/libsql/migrator.d.ts */
export declare function migrate<TSchema extends Record<string, unknown>>(db: LibSQLDatabase<TSchema>, config: MigrationConfig): Promise<void>;
// here only accepts MigrationConfig
/**
@file drizzle-orm/migrator.d.ts
This is the first call of the function migrate() from libsql export
*/
readMigrationFiles(config: string | MigrationConfig): MigrationMeta[];
// here accepts both types

/** @file drizzle-orm/libsql/migrator.d.ts */
export declare function migrate<TSchema extends Record<string, unknown>>(db: LibSQLDatabase<TSchema>, config: MigrationConfig): Promise<void>;
// here only accepts MigrationConfig
7 replies
DTDrizzle Team
Created by RaSk on 5/11/2024 in #help
drizzle-kit push from JS
Ok I found out about drizzle-orm/libsql/migrator but it seems there is a type issue with the config 🤔
7 replies
DTDrizzle Team
Created by delight on 9/30/2023 in #help
Drizzle Studio on postgres
import type { Config } from 'drizzle-kit';
import { loadEnvConfig } from '@next/env';

loadEnvConfig('./');

export default {
schema: './db/schema.ts',
out: './drizzle',
driver: 'pg',
dbCredentials: {
connectionString: process.env.POSTGRES_URL_DRIZZLE_STUDIO ?? ''
}
} satisfies Config;
import type { Config } from 'drizzle-kit';
import { loadEnvConfig } from '@next/env';

loadEnvConfig('./');

export default {
schema: './db/schema.ts',
out: './drizzle',
driver: 'pg',
dbCredentials: {
connectionString: process.env.POSTGRES_URL_DRIZZLE_STUDIO ?? ''
}
} satisfies Config;
9 replies
DTDrizzle Team
Created by delight on 9/30/2023 in #help
Drizzle Studio on postgres
using the pg driver but you need to add ?sslmode=require to the Vercel URL
9 replies
DTDrizzle Team
Created by delight on 9/30/2023 in #help
Drizzle Studio on postgres
I'm using @vercel/postgres it works btw
9 replies
DTDrizzle Team
Created by delight on 9/30/2023 in #help
Drizzle Studio on postgres
I had the same problem the other day and thought about opening an Issue with PR too 😉
9 replies