P
Prisma2w ago
jpcafe

db push not working with new prisma.config `migrate` adapter

hey guys, anyone got db push to work with turso? getting
error: Error validating datasource `db`: the URL must start with the protocol `file:`.
--> prisma/schema.prisma:11
|
10 | provider = "sqlite"
11 | url = env("DATABASE_URL")
|
error: Error validating datasource `db`: the URL must start with the protocol `file:`.
--> prisma/schema.prisma:11
|
10 | provider = "sqlite"
11 | url = env("DATABASE_URL")
|
5 Replies
Prisma AI Help
You're in no rush, so we'll let a dev step in. Enjoy your coffee, or drop into #ask-ai if you get antsy for a second opinion!
Nurul
Nurul2w ago
Hey 👋 It worked as expected to me. Here is my prisma.config.ts file:
import path from 'node:path';
import { defineConfig } from 'prisma/config';
import { PrismaLibSQL } from '@prisma/adapter-libsql';

// import your .env file
import 'dotenv/config';

type Env = {
LIBSQL_DATABASE_URL: string;
LIBSQL_DATABASE_TOKEN: string;
};

export default defineConfig<Env>({
earlyAccess: true,
schema: path.join('prisma', 'schema.prisma'),

migrate: {
async adapter(env) {
return new PrismaLibSQL({
url: env.LIBSQL_DATABASE_URL,
authToken: env.LIBSQL_DATABASE_TOKEN,
});
},
},
});
import path from 'node:path';
import { defineConfig } from 'prisma/config';
import { PrismaLibSQL } from '@prisma/adapter-libsql';

// import your .env file
import 'dotenv/config';

type Env = {
LIBSQL_DATABASE_URL: string;
LIBSQL_DATABASE_TOKEN: string;
};

export default defineConfig<Env>({
earlyAccess: true,
schema: path.join('prisma', 'schema.prisma'),

migrate: {
async adapter(env) {
return new PrismaLibSQL({
url: env.LIBSQL_DATABASE_URL,
authToken: env.LIBSQL_DATABASE_TOKEN,
});
},
},
});
And this was my schema.prisma file:
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
provider = "prisma-client-js"
previewFeatures = ["driverAdapters"]
}

datasource db {
provider = "sqlite"
url = "file:./dev.db"
}

model User {
id Int @id @default(autoincrement())
name String
email String
profile String?
}
// This is your Prisma schema file,
// learn more about it in the docs: https://pris.ly/d/prisma-schema

generator client {
provider = "prisma-client-js"
previewFeatures = ["driverAdapters"]
}

datasource db {
provider = "sqlite"
url = "file:./dev.db"
}

model User {
id Int @id @default(autoincrement())
name String
email String
profile String?
}
It worked as expected for me
Nurul
Nurul2w ago
No description
jpcafe
jpcafeOP7d ago
Yes thank you! My mistake was having the same DATABASE_URL in prisma schema!
Nurul
Nurul7d ago
No worries! I am glad to hear that you were able to make it work 👍

Did you find this page helpful?