@take-out/postgres 0.0.41 → 0.0.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +37 -22
  2. package/package.json +3 -4
package/README.md CHANGED
@@ -104,26 +104,39 @@ await migrate({
104
104
 
105
105
  ## CLI
106
106
 
107
- The package includes a CLI with several database utilities:
107
+ The package includes a CLI with several database utilities. Run with `bunx postgres` or `bun env:dev bunx postgres` (to load env vars):
108
108
 
109
109
  ```bash
110
110
  # show help
111
- db --help
111
+ bunx postgres --help
112
112
 
113
113
  # connect to database with psql
114
- db psql
114
+ bun env:dev bunx postgres psql
115
115
 
116
- # create a new migration
117
- db migrate:add my-migration-name
116
+ # run a query directly
117
+ bun env:dev bunx postgres psql --query "SELECT * FROM users LIMIT 5"
118
118
 
119
- # run migrations
120
- db migrate
119
+ # create a new migration
120
+ bunx postgres migrate:add my-migration-name
121
121
 
122
122
  # dump database
123
- db pg_dump > backup.sql
123
+ bun env:dev bunx postgres pg_dump > backup.sql
124
124
 
125
- # sync drizzle migrations to TypeScript
126
- db sync
125
+ # sync drizzle migrations to TypeScript wrappers
126
+ bunx postgres sync-drizzle
127
+ ```
128
+
129
+ For migrations, use the project scripts:
130
+
131
+ ```bash
132
+ # local dev - generates and runs migrations
133
+ bun migrate run
134
+
135
+ # production - generates and builds
136
+ bun migrate build
137
+
138
+ # add a custom typescript migration
139
+ bun db:migrate-add my-migration-name
127
140
  ```
128
141
 
129
142
  ### CLI Configuration
@@ -136,19 +149,20 @@ The CLI uses environment variables for configuration:
136
149
 
137
150
  ## Migration System
138
151
 
139
- ### SQL Migrations (Drizzle Kit)
152
+ The migration system combines Drizzle schema migrations with custom TypeScript
153
+ migrations. You don't need to run Drizzle commands directly.
154
+
155
+ ### Schema Migrations
140
156
 
141
- 1. Update your schema files
142
- 2. Generate migration: `drizzle-kit generate`
143
- 3. Sync to TypeScript: `db sync`
144
- 4. Run migrations: `db migrate`
157
+ 1. Update `src/database/schema-public.ts` or `schema-private.ts`
158
+ 2. Run `bun migrate run` (generates + runs migrations)
145
159
 
146
- ### TypeScript Migrations
160
+ ### Custom TypeScript Migrations
147
161
 
148
- For custom data migrations:
162
+ For data migrations or changes that can't be expressed in schema:
149
163
 
150
164
  ```bash
151
- db migrate:add fix-user-data
165
+ bun db:migrate-add fix-user-data
152
166
  ```
153
167
 
154
168
  This creates a new TypeScript file:
@@ -157,17 +171,18 @@ This creates a new TypeScript file:
157
171
  import type { PoolClient } from 'pg'
158
172
 
159
173
  export async function up(client: PoolClient) {
160
- // your migration code here
161
174
  await client.query(`
162
175
  UPDATE users SET email = lower(email)
163
176
  `)
164
177
  }
165
178
  ```
166
179
 
167
- ### Migration Sync
180
+ ### How It Works
168
181
 
169
- The `db sync` command automatically wraps Drizzle-generated SQL migrations in
170
- TypeScript:
182
+ The `bun migrate build` command:
183
+ 1. Runs `drizzle-kit generate` to create SQL migrations from schema changes
184
+ 2. Wraps SQL migrations in TypeScript (using `?raw` imports)
185
+ 3. Bundles all migrations into a single deployable file
171
186
 
172
187
  ```typescript
173
188
  // migrations/0001_example.sql → migrations/0001_example.ts
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@take-out/postgres",
3
- "version": "0.0.41",
3
+ "version": "0.0.43",
4
4
  "sideEffects": false,
5
5
  "source": "src/index.ts",
6
6
  "main": "dist/cjs",
@@ -53,7 +53,7 @@
53
53
  }
54
54
  },
55
55
  "dependencies": {
56
- "@take-out/helpers": "0.0.41",
56
+ "@take-out/helpers": "0.0.43",
57
57
  "async-retry": "^1.3.3",
58
58
  "citty": "^0.1.6"
59
59
  },
@@ -62,10 +62,9 @@
62
62
  "pg": "^8.16.3"
63
63
  },
64
64
  "devDependencies": {
65
- "@tamagui/build": "*",
65
+ "@tamagui/build": "^2.0.0-1768869088163",
66
66
  "@types/async-retry": "^1.4.8",
67
67
  "@types/node": "24.0.3",
68
- "drizzle-kit": "^0.30.5",
69
68
  "drizzle-orm": "^0.40.0",
70
69
  "oxfmt": "^0.16.0",
71
70
  "oxlint": "^1.31.0"