Daniell
02/17/2021, 4:34 PM52,081318
, 4,324105
etc, currently in my prisma schema I have
lat Float @db.DoublePrecision
is this fine or should I change it?Mike Cavaliere
02/17/2021, 5:45 PMmigrate deploy
command for example, since it'll migrate the prod DB while deploying to preview.Jamey Nakama
02/17/2021, 8:59 PMprisma migrate deploy
instead of migrate dev
and it generally will work out? Or do I have to mark each migration first with resolve
?owen
02/18/2021, 4:30 AMAdam
02/20/2021, 10:46 PMschema
specific (postgres), so attempting to auto-generate new schemas to run automated tests on doesnt work out so wellCristian Salamea
02/23/2021, 8:24 PMCristian Salamea
02/24/2021, 6:32 AMJulien Blatecky
02/25/2021, 11:41 AMError: Database error: Error querying the database: db error: ERROR: cannot drop type "AdminRoleType" because other objects depend on it
DETAIL: column type of table "AdminRole" depends on type "AdminRoleType"
HINT: Use DROP ... CASCADE to drop the dependent objects too.
0: sql_migration_connector::sql_database_step_applier::apply_migration
at migration-engine/connectors/sql-migration-connector/src/sql_database_step_applier.rs:14
1: sql_migration_connector::best_effort_reset
with connection=Connection(Postgres(PostgresUrl { url: Url { scheme: "postgresql", host: Some(Domain("<http://bj175749-001.dbaas.ovh.net|bj175749-001.dbaas.ovh.net>")), port: Some(35982), path: "/jda-develop-shadow", query: None, fragment: None }, query_params: PostgresUrlQueryParams { ssl_params: SslParams { certificate_file: None, identity_file: None, identity_password: <HIDDEN>, ssl_accept_mode: AcceptInvalidCerts }, connection_limit: None, schema: "public", ssl_mode: Prefer, pg_bouncer: false, host: None, socket_timeout: None, connect_timeout: Some(5s), pool_timeout: Some(5s), statement_cache_size: 500 } }))
at migration-engine/connectors/sql-migration-connector/src/lib.rs:104
2: sql_migration_connector::flavour::postgres::sql_schema_from_migration_history
at migration-engine/connectors/sql-migration-connector/src/flavour/postgres.rs:270
3: sql_migration_connector::sql_database_migration_inferrer::validate_migrations
at migration-engine/connectors/sql-migration-connector/src/sql_database_migration_inferrer.rs:70
4: migration_core::api::DevDiagnostic
at migration-engine/core/src/api.rs:79
Nikolai Nergård
02/25/2021, 1:41 PMDATABASE_URL="<postgres://adminer>:testpw@localhost:5432/365manager-core-api"
My docker compose is like this:
version: '3.8'
services:
postgres:
image: postgres:10.3
restart: always
environment:
- POSTGRES_USER=adminer
- POSTGRES_PASSWORD=testpw
volumes:
- postgres:/var/lib/postgresql/data
ports:
- '5432:5432'
volumes:
postgres:
I then did docker-compose up
and the docker DB gets created and seems to be running.
I'm don't really know the name of the DB, after some experimenting it seems to default to the name of the root project folder. Any way to specify it, or verify what it is?
Finally I tried prisma migrate dev --preview-feature
which gives the following error:
Environment variables loaded from .env
Prisma schema loaded from prisma\schema.prisma
Datasource "db": PostgreSQL database "365manager-core-api", schema "public" at "localhost:5432"
Error: P1001: Can't reach database server at `localhost`:`5432`
maxweld
03/08/2021, 9:43 AMError: Schema parsing
error: Error validating: The relation field `defaultAddrs` uses the scalar fields defaultAddr. All those fields are optional. Hence the relation field must
be optional as well.
--> schema.prisma:48
|
47 | player Player[] // 11
48 | defaultAddrs Address @relation(fields: [defaultAddr], references: [id]) // 23
49 |
|
Validation Error Count: 1
The only change in the schema was to set the 'defaultAddr' scalar field to nullable (i.e. I added a '?').
Is this a bug with migrate or am I misunderstanding something.Bryan Migliorisi
03/11/2021, 9:38 PMchrisdhanaraj
03/21/2021, 11:21 PMmodel UserItem {
providerItemId Int
userId Int
listItems. ListItem[]
@@id([userId, providerItemId])
}
modal ListItem {
...
userId Int
providerItemId Int
userItem UserItem @relation(fields: [userId, providerItemId], references: [userId, providerItemId])
}
When trying to apply a migrate for this, I run into an error of
Error: Database error: Foreign key constraint failed: ListItem_userId_fkey1
0: migration_core::api::ApplyMigrations
at migration-engine/core/src/api.rs:75
Any tips on trying to track this one down?ludovic
03/24/2021, 7:48 AMzach
03/24/2021, 2:15 PM@@unique([accountId, productId])
in a model. When I run prisma migrate dev
in the generated migration it creates an index named Table.accountId_productId_unique
(which makes sense, to avoid naming conflicts).
However if I then run prisma introspect
it updates my schema to @@unique([accountId, productId], name: "Table.accountId_productId_unique")
, and if I run prisma generate it creates a broken client.
Is this intended behavior? Should I not use introspect with migrate?Daniell
03/28/2021, 2:42 PMpgloader
to import the MySQL database in Postgres and ran npx prisma introspect
against the Postgres database, now I want to move to the Prisma migrate API but when introspecting, I got:
The following models were commented out as they do not have a valid unique identifier or id. This is currently not supported by the Prisma Client.
for all many-to-many middleware tables, is it safe to ignore it? If not, what are the right steps to fix them?
Example:
/// The underlying table does not contain a valid unique identifier and can therefore currently not be handled by the Prisma Client.
model campaign_shops {
campaign_id BigInt?
shop_id BigInt?
campaigns campaigns? @relation(fields: [campaign_id], references: [id])
shops shops? @relation(fields: [shop_id], references: [id])
@@index([campaign_id], name: "xxx")
@@index([shop_id], name: "xxx1")
@@ignore
}
I'm not sure if I need to change anything when I move to the migrate apiDaniell
04/01/2021, 10:08 AMnpx prisma introspect
model A {
id Int @id @default(autoincrement()) @db.UnsignedInt
from DateTime @default(dbgenerated("00:00:00")) @db.Time
}
2. npx prisma migrate dev
We need to reset the MySQL database "a" at "localhost:3306".
Do you want to continue? All data will be lost. … yes
? Name of migration › init
Error: Database error
Error querying the database: Server error: `ERROR 42000 (1064): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':00:00,
`from` TIME NOT NULL DEFAULT 00:00:00,
I tried to do npx prisma migrate dev --create-only
to edit 000000 to "000000"
but when I then run npx prisma migrate dev
it asks for a new migration name and the new one generates the wrong time as well so it asks for a new name after fixing the quote issue againSimon Rycroft
04/01/2021, 3:11 PMprisma migrate
without a .env
file please e.g. by reading from env vars or providing custom config to a PrismaClient
like you can in the app?Daniell
04/02/2021, 6:45 AMfrom DateTime @default(dbgenerated("\"00:00:00\"")) @db.Time(0)
using mysql everytime you run migrate dev
it asks for a new migration name and it keeps generating the same
-- AlterTable
ALTER TABLE `test` MODIFY `from` TIME(0) NOT NULL DEFAULT "00:00:00",
MODIFY `until` TIME(0) NOT NULL DEFAULT "00:00:00";
Is this a bug or am I missing something? 😅 I created a issue just in case https://github.com/prisma/prisma/issues/6382Vadymski
04/04/2021, 6:27 PMnpx prisma migrate dev
, the error:
Error: P3006
Migration `20210404180101_init` failed to apply cleanly to a temporary database.
Error:
Database error
Error querying the database: db error: ERROR: function uuid_generate_v4() does not exist
HINT: No function matches the given name and argument types. You might need to add explicit type casts.
0: sql_migration_connector::flavour::postgres::sql_schema_from_migration_history
at migration-engine/connectors/sql-migration-connector/src/flavour/postgres.rs:278
1: sql_migration_connector::sql_database_migration_inferrer::validate_migrations
at migration-engine/connectors/sql-migration-connector/src/sql_database_migration_inferrer.rs:88
2: migration_core::api::DevDiagnostic
at migration-engine/core/src/api.rs:95
The problem is uuid-ossp
extension is installed, i can see it in my IDE and when run \x
in psql in terminal.
Also, when i run db push
, everything works fine. It looks like the problem is when prisma tries to create a shadow database, but did not install required extension. I also tried to add additional environment for shadow database as per manual on the prisma website for cloud database instances, but still get the same error.
My schema mostly contains such @ids:
model User {
id String @id @default(dbgenerated("uuid_generate_v4()")) @db.Uuid
// ... other fields
}
// ... other models with similar declaration of primary key
Also, i tried to edit init
migration file, and write on the top of it CREATE EXTENSION "uuid-ossp";
, when i run such migration it says that uuid-ossp
already installed 😕
Did i missed something, or is this a bug?Nikolai Nergård
04/07/2021, 2:00 PMHassan
04/07/2021, 5:50 PMAndrew Leung
04/14/2021, 7:00 PM.env
file to use when specifying my DATABASE_URL
. For example, my workflow for local development uses a .env.local
file which has been `.gitignore`'d to ensure no leakage of secrets. So when I make a migration, I'd like to be able to specify .env.local
instead.Pranav Sathyanarayanan
04/24/2021, 3:43 PMuuid
PKs like so:
uuid String @id @default(dbgenerated("gen_random_uuid()::TEXT"))
However, no matter how many migrations we run, Prisma Migrate still generates SQL like:
-- AlterTable
ALTER TABLE "User" ALTER COLUMN "uuid" SET DEFAULT gen_random_uuid()::TEXT;
Has anyone else experienced this issue, and how to resolve it?Matt Leyrat
05/18/2021, 7:53 PM.env
, we instantiate the PrismaClient after parsing the config-server response, and programmatically override the datasource url as shown in these docs.
The issue is that we don’t have the database credentials until the app starts. So we don’t have a datasource url when running prisma migrate deploy
in CD.
What is the suggested approach to running migrations in CD when the datasource url is set programmatically in production?Nikolai Nergård
05/20/2021, 2:51 PMRichard Lee
05/26/2021, 11:36 PMDan Shapir
06/03/2021, 10:04 PMsven
06/04/2021, 10:59 AMJesús Quirós
06/08/2021, 4:30 PMmodel Account {
id String @id @default(dbgenerated("my_schema.uuid_generate_v4()")) @db.Uuid
...
@@map(name: "accounts")
}
model Product {
id String @id @default(dbgenerated("my_schema.uuid_generate_v4()")) @db.Uuid
...
@@map(name: "products")
}
Every time I create or apply a migration Prisma generates the alter for the id columns despite the fact that those columns did not change:
-- AlterTable
ALTER TABLE "accounts" ALTER COLUMN "id" SET DEFAULT my_schema.uuid_generate_v4();
-- AlterTable
ALTER TABLE "products" ALTER COLUMN "id" SET DEFAULT my_schema.uuid_generate_v4();
Is this a bug? Am I doing something wrong here?
Environment:
prisma ^2.24.1
PostgreSQL 13.2
Thanks in advance for your help 🙂sven
06/09/2021, 2:00 PMSELECT * FROM pg_extension
but it doesn’t work for my schema/tables.
-- migration.sql
CREATE EXTENSION IF NOT EXISTS pg_trgm;
It does work if I manually install it through a terminal with admin user
What is the right way to install an extension? Should I run migrate with admin privileges?
PS: I am using a schema… does that matter?