iska
iska
Explore posts from servers
DTDrizzle Team
Created by Δάρκζυ on 8/19/2024 in #help
How can I handle ID collisions
its built in
10 replies
DTDrizzle Team
Created by Δάρκζυ on 8/19/2024 in #help
How can I handle ID collisions
just use built in crypto.randomUUID()
10 replies
DTDrizzle Team
Created by iska on 8/19/2024 in #help
syntax atomic transaction d1 not working
i saw this https://orm.drizzle.team/docs/batch-api seems like d1 doesnt support atomic transaction initiated by the user itself but batch-api seems to have performance drawback 😦
3 replies
DTDrizzle Team
Created by iska on 8/8/2024 in #help
using a monorepo with multiple apps and services
downside is to write manually all the schema 🙂
12 replies
DTDrizzle Team
Created by iska on 8/8/2024 in #help
using a monorepo with multiple apps and services
this way only one drizzle config is required then using DB_NAME variable i can map them to schemaMap and manage my migration per app
12 replies
DTDrizzle Team
Created by iska on 8/8/2024 in #help
using a monorepo with multiple apps and services
ok found an idea if anyone ever needs something
import { defineConfig, Config } from 'drizzle-kit';

const schemaMap = {
tiktok: ['./libs/backend/services/models/src/lib/schema.ts'],
aideator: ['./libs/backend/services/models/src/lib/schema.ts'],
}


const localConfig: Config = {
schema: schemaMap[process.env.DB_NAME],
out: `./wranglers/migrations/${process.env.DB_NAME}`,
dialect: 'sqlite',
dbCredentials: {
url: process.env.LOCAL_DB_PATH,
},
};

const cloudConfig: Config = {
schema: schemaMap[process.env.DB_NAME],
out: `./wranglers/migrations/${process.env.DB_NAME}`,
dialect: 'sqlite',
driver: 'd1-http',
dbCredentials: {
accountId: process.env.ACCOUNT_ID,
databaseId:process.env.D1_DATABASE_ID,
token: process.env.D1_TOKEN,
},
};

export default defineConfig(process.env.LOCAL_DB_PATH ? localConfig : cloudConfig);
import { defineConfig, Config } from 'drizzle-kit';

const schemaMap = {
tiktok: ['./libs/backend/services/models/src/lib/schema.ts'],
aideator: ['./libs/backend/services/models/src/lib/schema.ts'],
}


const localConfig: Config = {
schema: schemaMap[process.env.DB_NAME],
out: `./wranglers/migrations/${process.env.DB_NAME}`,
dialect: 'sqlite',
dbCredentials: {
url: process.env.LOCAL_DB_PATH,
},
};

const cloudConfig: Config = {
schema: schemaMap[process.env.DB_NAME],
out: `./wranglers/migrations/${process.env.DB_NAME}`,
dialect: 'sqlite',
driver: 'd1-http',
dbCredentials: {
accountId: process.env.ACCOUNT_ID,
databaseId:process.env.D1_DATABASE_ID,
token: process.env.D1_TOKEN,
},
};

export default defineConfig(process.env.LOCAL_DB_PATH ? localConfig : cloudConfig);
12 replies
DTDrizzle Team
Created by iska on 8/8/2024 in #help
using a monorepo with multiple apps and services
unless there is a more elegant solution ?
12 replies
DTDrizzle Team
Created by iska on 8/8/2024 in #help
using a monorepo with multiple apps and services
i m not sure this answers my issues when running generate to generate your migrations files it will then create those migrations files for a single db which is fine if you dont have any shared generic models that can also apply to another DB say for example user model that is shared to app1 and app2 migrations will be created once based on the change they detect right ? so the only way atm is to filter those shared schema and then dispatch them by cloning them to your multiple db
12 replies
DTDrizzle Team
Created by iska on 8/8/2024 in #help
using a monorepo with multiple apps and services
i would very much like avoid creating multiple drizzle config file which is also a solution but that looks kind of odd to have ten of those on my root level
12 replies