Yilmaz Ugurlu
10/07/2021, 3:34 PMBu when I do and runWhile you cannot configure these option in your Prisma schema, you can still configure them on the database-level directly.
migrate
I get:
Drift detected: Your database schema is not in sync with your migration history.
The following is a summary of the differences between the expected database schema given your migrations files, and the actual schema of the database.
It should be understood as the set of changes to get from the expected schema to the actual schema.
[*] Changed the `event` table
[+] Added index on columns (created_at, event_name)
[+] Added index on columns (created_at, event_name)
[+] Added index on columns (created_at, event_name)
So, what am I doing wrong here? Any idea?Ryan
10/08/2021, 5:43 AMprisma migrate dev --create-only
2. Add the indexes to the created .sql
file
3. Run prisma migrate dev
to apply the migration and the indexes will be added.Yilmaz Ugurlu
10/08/2021, 7:31 AMDrop index
commands.
-- DropIndex
DROP INDEX "api_an_idx";
-- DropIndex
DROP INDEX "user_an_idx";
Yilmaz Ugurlu
10/08/2021, 7:31 AMYilmaz Ugurlu
10/08/2021, 7:32 AMmodel Event {
id String @id @default(uuid()) @db.VarChar(40)
createdAt DateTime @default(now()) @map(name: "created_at")
event_name String @db.VarChar(64)
entity Json
@@map(name: "event")
}
this is my schema btw.Ryan
10/08/2021, 7:35 AMYilmaz Ugurlu
10/08/2021, 7:41 AMCREATE EXTENSION if not exists btree_gin;
create index user_an_idx
on event using gin (created_at, event_name, (entity -> 'user'));
create index api_an_idx
on event using gin (created_at, event_name, (entity -> 'api_key'));
Yilmaz Ugurlu
10/08/2021, 7:42 AM@@ignore
to pass client code creation, that I can access to this table by raw sql.Yilmaz Ugurlu
10/08/2021, 7:44 AMYilmaz Ugurlu
10/08/2021, 9:22 AMmodel Event {
createdAt DateTime @default(now()) @map(name: "created_at")
event_name String @db.VarChar(64)
entity Json
@@index(fields: [createdAt, event_name], map: "user_an_idx")
@@index(fields: [createdAt, event_name], map: "api_an_idx")
@@map(name: "event")
@@ignore
}
run prisma migrate dev --create-only
then added:
CREATE EXTENSION if not exists btree_gin;
drop index if exists user_an_idx;
drop index if exists api_an_idx;
-- index for user events
create index user_an_idx
on event using gin (created_at, event_name, (entity -> 'user'));
-- index for api events
create index api_an_idx
on event using gin (created_at, event_name, (entity -> 'api_key'));
Now reflected all the changes without dropping the index.Yilmaz Ugurlu
10/08/2021, 9:22 AM