This error occurs when you try to run Prisma migrations with an outdated schema format that uses arrays for datasource providers. Prisma migrated from array-based provider definitions to single provider strings, requiring schema updates before migrations can proceed.
The P3013 error is a migration error that occurs when Prisma detects an outdated schema format in your `schema.prisma` file. In earlier versions of Prisma, datasource providers could be specified as arrays to support multiple database providers. However, this feature was deprecated and removed in favor of single provider strings. When you run `prisma migrate dev` or `prisma migrate deploy`, Prisma checks your schema for compatibility. If it finds array syntax like `provider = ["postgresql", "mysql"]` or `provider = ["sqlite"]`, it throws this error because the migration engine no longer supports parsing these array definitions. This change was made to simplify the schema format and improve type safety. Instead of arrays, you now specify a single provider string like `provider = "postgresql"`. The error prevents migrations from running until you update your schema to the new format.
Open your schema.prisma file and look for the datasource block. Check if the provider field uses array syntax:
// OLD FORMAT (causes error)
datasource db {
provider = ["postgresql"] // or ["mysql"], ["sqlite"], ["sqlserver"], ["cockroachdb"]
url = env("DATABASE_URL")
}
// Also check for multiple providers:
datasource db {
provider = ["postgresql", "mysql"] // This will cause the error
url = env("DATABASE_URL")
}The error occurs because Prisma no longer supports array notation for the provider field.
Update the provider field to use a single string value instead of an array:
// NEW FORMAT (correct)
datasource db {
provider = "postgresql" // Single string, no brackets
url = env("DATABASE_URL")
}If you had multiple providers in the array, you need to choose one primary database provider. Prisma no longer supports declaring multiple providers in a single datasource.
Check your Prisma version to ensure you're using a compatible version:
npx prisma --versionIf you're using a very old version of Prisma (before 3.0.0), consider upgrading to a more recent version. The array syntax was deprecated around Prisma 2.x and removed in later versions.
Update Prisma if needed:
npm install @prisma/client@latest
npm install prisma@latest --save-devAfter updating your schema.prisma file, try running the migration command again:
npx prisma migrate devOr if you're deploying to production:
npx prisma migrate deployThe error should no longer appear, and migrations should proceed normally. If you still encounter issues, check for other outdated syntax in your schema.
If you previously used provider arrays to support multiple databases, you now need a different approach:
1. Separate schemas: Create separate schema.prisma files for each database environment
2. Environment variables: Use different DATABASE_URL values for different environments
3. Database abstraction: Consider using a database abstraction layer if you need to support multiple database types
Example for multiple environments:
// schema.prisma (development - PostgreSQL)
datasource db {
provider = "postgresql"
url = env("DEV_DATABASE_URL")
}
// schema.test.prisma (testing - SQLite)
datasource db {
provider = "sqlite"
url = env("TEST_DATABASE_URL")
}Use different schema files with the --schema flag:
npx prisma migrate dev --schema=./prisma/schema.test.prismaHistorical Context: The array syntax for datasource providers was introduced in early Prisma 2.x versions as an experimental feature to allow schema definitions that could target multiple database types. This was particularly useful for projects that needed to support different databases in development vs production (e.g., SQLite locally, PostgreSQL in production).
Why it was removed: The feature was removed because:
1. It added complexity to the Prisma migration engine
2. It caused confusion about which database was actually being used
3. Most users only needed a single database provider
4. It complicated type generation and query optimization
Migration path: When Prisma removed this feature, they provided a migration path where the first element of the array would be used as the single provider. So ["postgresql", "mysql"] would become "postgresql".
Checking other outdated syntax: While fixing the P3013 error, also check for other deprecated syntax in your schema:
- Old generator syntax: provider = "prisma-client-js" (should be lowercase)
- Deprecated relation syntax: @relation(name: "UserPosts", fields: [authorId], references: [id])
- Old enum syntax (if using very old Prisma versions)
Prevention: To avoid this error in the future:
1. Keep Prisma and its dependencies updated regularly
2. Review breaking changes in Prisma release notes
3. Use Prisma's version compatibility checks
4. Maintain a single, clear database provider per environment
P6005: Invalid parameters (Pulse)
How to fix "P6005: Invalid parameters (Pulse)" in Prisma
P2011: Null constraint violation on the field
How to fix "P2011: Null constraint violation" in Prisma
P2009: Failed to validate the query: {validation_error}
How to fix "P2009: Failed to validate the query" in Prisma
P2007: Data validation error
How to fix "P2007: Data validation error" in Prisma
P1013: The provided database string is invalid
The provided database string is invalid