drizzle-team / drizzle-orm

Headless TypeScript ORM with a head. Runs on Node, Bun and Deno. Lives on the Edge and yes, it's a JavaScript ORM too 😅
https://orm.drizzle.team
Apache License 2.0
23.13k stars 564 forks source link

[FEATURE]:Support multiple branch development ? #1221

Open abcfy2 opened 1 year ago

abcfy2 commented 1 year ago

Describe what you want

When we develop on different branches, will cause migrate sql lost when merge.

This because of the sql:

Query: CREATE SCHEMA IF NOT EXISTS "drizzle"
Query: 
            CREATE TABLE IF NOT EXISTS "drizzle"."__drizzle_migrations" (
                id SERIAL PRIMARY KEY,
                hash text NOT NULL,
                created_at bigint
            )

Query: select id, hash, created_at from "drizzle"."__drizzle_migrations" order by created_at desc limit 1
Query: begin
Query: commit

When I generate migrate sql on different branches, will cause conflict. See the final result:

❯ tree drizzle
drizzle
├── 0000_calm_talos.sql
├── 0001_reflective_malice.sql
├── 0002_careful_northstar.sql
├── 0003_blushing_martin_li.sql
├── 0004_bumpy_katie_power.sql
├── 0004_even_cyclops.sql
├── 0006_luxuriant_bloodscream.sql
└── meta
    ├── 0000_snapshot.json
    ├── 0001_snapshot.json
    ├── 0002_snapshot.json
    ├── 0003_snapshot.json
    ├── 0004_snapshot.json
    ├── 0006_snapshot.json
    └── _journal.json

2 directories, 14 files

You can see there're 2 0004_ sqls here.

So if 0004_even_cyclops.sql first migrate, then merge branch with file 0004_bumpy_katie_power.sql, will cause 0004_bumpy_katie_power.sql never execute, this because the sql of migrate:

select id, hash, created_at from "drizzle"."__drizzle_migrations" order by created_at desc limit 1

I hope you can support multiple branches development. Thanks.

croshim commented 1 month ago

Hi, any updates on that? How should we work with migrations if multiple developers are working in various branches and creating migrations?