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
24.45k stars 641 forks source link

[FEATURE]: Push feature for Dirzzle-orm #1340

Open ansarizafar opened 1 year ago

ansarizafar commented 1 year ago

Describe what you want

I am using libsql and I am building a desktop and a mobile app. I can't bundle migrations folder with my app. Dirizzle-kit has a push command for altering database schema rapidly but we can't push changes with drizzle-orm at runtime.

lLike migrate, please provide a push function with drizzle-orm for schema modifications without first generating the migration scripts.

ansarizafar commented 1 year ago

@AndriiSherman Is it possible to add push schema feature to Drizzle-ORM?

hugo082 commented 11 months ago

Would be very useful to generate memory based SQL clients for testing purposes:

import { createClient } from '@libsql/client';
import { pushSchema } from 'drizzle-orm';
import { drizzle } from 'drizzle-orm/libsql';

import { schema } from './schema';

export const createDatabaseClientMock = () => {
  const client = createClient({ url: ':memory:' });

  const db = drizzle(client);

  await pushSchema(schema, db)

  return db;
};
riccox commented 6 months ago

Would be very useful to generate memory based SQL clients for testing purposes:

import { createClient } from '@libsql/client';
import { pushSchema } from 'drizzle-orm';
import { drizzle } from 'drizzle-orm/libsql';

import { schema } from './schema';

export const createDatabaseClientMock = () => {
  const client = createClient({ url: ':memory:' });

  const db = drizzle(client);

  await pushSchema(schema, db)

  return db;
};

@hugo082 I'm using v0.30.10, it does not have this command. Module '"drizzle-orm"' has no exported member 'pushSchema'

ansarizafar commented 1 month ago

Is there any progress on this issue? Push feature will also be useful for migrating PGLite schema.

L-Mario564 commented 4 weeks ago

Kit now exposes it's API which includes a push function. This isn't documented though.

ansarizafar commented 2 weeks ago

@L-Mario564 Could you please share a code sample or a link about Kit push API?