Table of Contents
Random Turso stuff
Turso stuff that I don't know where to put
Database setup
docker run --name dbname -ti -v ./libsql-data:/var/lib/sqld -e SQLD_NODE=primary -p 8080:8080 ghcr.io/tursodatabase/libsql-server:latest
Connection details:
- URL:
http://localhost:8080 - Token:
1(needs to be a value, doesn't work otherwise)
Backup database
wget --header="Authorization: Bearer TOKEN" -O output.sql "https://dbname-organizationname.turso.io/dump"
generates a output.sql file
Restore database
turso db shell http://localhost:8080 < output.sql
Client Migration not working
How to fix the following drizzle error:
[⣷] applying migrations...TypeError: this.client.migrate is not a function
move your migration command from drizzle-kit migrate to tsx migrate.ts with the content similar to this:
migrate.ts
import 'dotenv/config';
import { drizzle } from 'drizzle-orm/libsql';
import { migrate } from 'drizzle-orm/libsql/migrator';
import { createClient } from '@libsql/client';
if (!process.env.TURSO_URL) throw new Error('TURSO_URL is not set');
if (!process.env.TURSO_TOKEN) throw new Error('TURSO_TOKEN is not set');
async function main() {
const client = createClient({
url: process.env.TURSO_URL,
authToken: process.env.TURSO_TOKEN,
});
const db = drizzle(client);
console.log('Running migrations...');
await migrate(db, { migrationsFolder: './drizzle' });
console.log('Migrations complete!');
process.exit(0);
}
main().catch(console.error);