Skip to content

Commit 3753d10

Browse files
Merge pull request #149 from drizzle-team/beta
Beta
2 parents 391e792 + 31c94dd commit 3753d10

File tree

230 files changed

+1181
-1314
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

230 files changed

+1181
-1314
lines changed

.github/workflows/release-feature-branch.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ jobs:
1111
matrix:
1212
package:
1313
- drizzle-orm
14-
- drizzle-orm-mysql
15-
- drizzle-orm-pg
16-
- drizzle-orm-sqlite
1714
- drizzle-zod
1815
runs-on: ubuntu-20.04
1916
steps:

.github/workflows/release-latest.yaml

+68-14
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@ on: workflow_dispatch
44

55
jobs:
66
release:
7+
permissions: write-all
78
strategy:
9+
fail-fast: false
810
matrix:
911
package:
1012
- drizzle-orm
11-
- drizzle-orm-mysql
12-
- drizzle-orm-pg
13-
- drizzle-orm-sqlite
1413
- drizzle-zod
1514
runs-on: ubuntu-20.04
1615
steps:
@@ -26,7 +25,10 @@ jobs:
2625
version: latest
2726
run_install: true
2827

29-
- name: Publish
28+
- name: Check preconditions
29+
id: checks
30+
shell: bash
31+
working-directory: ${{ matrix.package }}
3032
run: |
3133
latest="$(npm view --json ${{ matrix.package }} dist-tags.latest | jq -r)"
3234
version="$(jq -r .version package.json)"
@@ -35,22 +37,74 @@ jobs:
3537
echo "Latest: $latest"
3638
echo "Current: $version"
3739
38-
is_version_published="$(npm view ${{ matrix.package }} versions --json | jq -r '.[] | select(. == "'$version'") | . == "'$version'"')"
39-
if [[ "$is_version_published" == "true" ]]; then
40-
echo "Version $version already published, adding tag $tag"
41-
npm dist-tag add ${{ matrix.package }}@$version latest
42-
else
43-
echo echo "Publishing ${{ matrix.package }}@$version"
44-
(cd .. && npm run pack -- --filter ${{ matrix.package }})
45-
npm run publish
40+
changelogPath=$(node -e "console.log(require('path').resolve('..', 'changelogs', '${{ matrix.package }}', '$version.md'))")
41+
if [[ ! -f "$changelogPath" ]]; then
42+
echo "::error::Changelog for version $version not found: $changelogPath"
43+
exit 1
4644
fi
4745
48-
# Post release message to Discord
49-
curl -X POST -H "Content-Type: application/json" -d "{\"embeds\": [{\"title\": \"New \`${{ matrix.package }}\` release! 🎉\", \"url\": \"https://www.npmjs.com/package/${{ matrix.package }}\", \"color\": \"12907856\", \"fields\": [{\"name\": \"Tag\", \"value\": \"\`$tag\`\"}]}]}" ${{ secrets.DISCORD_RELEASE_WEBHOOK_URL }}
46+
{
47+
echo "version=$version"
48+
echo "has_new_release=true"
49+
echo "changelog_path=$changelogPath"
50+
} >> $GITHUB_OUTPUT
5051
else
5152
echo "Already up to date: $version"
53+
echo "\`$version\` is already latest on NPM" >> $GITHUB_STEP_SUMMARY
5254
fi
55+
56+
- name: Publish
57+
if: steps.checks.outputs.has_new_release == 'true'
5358
working-directory: ${{ matrix.package }}
5459
shell: bash
5560
env:
5661
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }}
62+
run: |
63+
version="${{ steps.checks.outputs.version }}"
64+
is_version_published="$(npm view ${{ matrix.package }} versions --json | jq -r '.[] | select(. == "'$version'") | . == "'$version'"')"
65+
66+
if [[ "$is_version_published" == "true" ]]; then
67+
echo "Version $version already published, adding tag $tag"
68+
npm dist-tag add ${{ matrix.package }}@$version latest
69+
else
70+
echo echo "Publishing ${{ matrix.package }}@$version"
71+
(cd .. && npm run pack -- --filter ${{ matrix.package }})
72+
npm run publish
73+
fi
74+
75+
echo "npm: \`+ ${{ matrix.package }}@$version\`" >> $GITHUB_STEP_SUMMARY
76+
77+
# Post release message to Discord
78+
curl -X POST -H "Content-Type: application/json" -d "{\"embeds\": [{\"title\": \"New \`${{ matrix.package }}\` release! 🎉\", \"url\": \"https://www.npmjs.com/package/${{ matrix.package }}\", \"color\": \"12907856\", \"fields\": [{\"name\": \"Tag\", \"value\": \"\`$tag\`\"}]}]}" ${{ secrets.DISCORD_RELEASE_WEBHOOK_URL }}
79+
80+
- name: Create GitHub release for ORM package
81+
uses: actions/github-script@v6
82+
if: matrix.package == 'drizzle-orm' && steps.checks.outputs.has_new_release == 'true'
83+
with:
84+
github-token: ${{ secrets.GITHUB_TOKEN }}
85+
script: |
86+
try {
87+
const fs = require("fs");
88+
const path = require("path");
89+
90+
const version = "${{ steps.checks.outputs.version }}";
91+
const changelog = fs.readFileSync("${{ steps.checks.outputs.changelog_path }}", "utf8");
92+
93+
const release = await github.rest.repos.createRelease({
94+
owner: context.repo.owner,
95+
repo: context.repo.repo,
96+
tag_name: `${version}`,
97+
name: `${version}`,
98+
body: changelog,
99+
});
100+
101+
await github.rest.repos.uploadReleaseAsset({
102+
owner: context.repo.owner,
103+
repo: context.repo.repo,
104+
release_id: release.data.id,
105+
name: `${{ matrix.package }}-${version}-dist.tgz`,
106+
data: fs.readFileSync(path.resolve("${{ matrix.package }}", "package.tgz")),
107+
});
108+
} catch (e) {
109+
core.setFailed(e.message);
110+
}

.github/workflows/unpublish-release-feature-branch.yaml

-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ jobs:
99
matrix:
1010
package:
1111
- drizzle-orm
12-
- drizzle-orm-mysql
13-
- drizzle-orm-pg
14-
- drizzle-orm-sqlite
1512
- drizzle-zod
1613
runs-on: ubuntu-20.04
1714
steps:

.markdownlint.yaml

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ first-line-h1: false
33
line-length: false
44
MD010:
55
spaces_per_tab: 2
6+
code_blocks: false

CONTRIBUTING.md

+22-17
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,23 @@ There are several ways how you can provide a feedback
3232

3333
## <a name="contributing"></a> Contribution guidelines
3434
---
35-
1. [General setup](#general-setup)
36-
- [Install node](#installing-node)
37-
- [Install pnpm](#installing-pnpm)
38-
- [Install docker](#installing-docker)
39-
2. [Local project setup](#local-project-setup)
40-
- [Clone project](#clone-project)
41-
3. [Building project](#building-project)
42-
- [Build project](#build-project)
43-
- [Run tests](#run-tests)
44-
4. [Commits and PRs](#commits-pr)
45-
- [Commit guideline](#commit-guideline)
46-
- [PR guideline](#pr-guideline)
35+
- [Contributing](#contributing)
36+
- [ Submitting bug report](#-submitting-bug-report)
37+
- [ Submitting feature request](#-submitting-feature-request)
38+
- [ Providing feedback](#-providing-feedback)
39+
- [ Contribution guidelines](#-contribution-guidelines)
40+
- [ General setup](#-general-setup)
41+
- [ Installing node](#-installing-node)
42+
- [ Install pnpm](#-install-pnpm)
43+
- [ Install docker](#-install-docker)
44+
- [ Local project setup](#-local-project-setup)
45+
- [ Clone project](#-clone-project)
46+
- [ Building project](#-building-project)
47+
- [ Build project](#-build-project)
48+
- [ Run tests](#-run-tests)
49+
- [ Commits and PRs](#-commits-and-prs)
50+
- [ Commit guideline](#-commit-guideline)
51+
- [ PR guideline](#-pr-guideline)
4752

4853
## <a name="general-setup"></a> General setup
4954
### <a name="installing-node"></a> Installing node
@@ -84,11 +89,11 @@ Project sctructure
8489
8590
📂 changelogs/ - all changelogs by modules
8691
87-
📂 drizzle-orm-pg/ - package with all resources for PostgreSQL database support
92+
📂 drizzle-orm/src/pg-core/ - package with all resources for PostgreSQL database support
8893
89-
📂 drizzle-orm-sqlite/ - package with all resources for SQLite database support
94+
📂 drizzle-orm/src/sqlite-core/ - package with all resources for SQLite database support
9095
91-
📂 drizzle-orm-mysql/ - package with all resources for MySQL database support
96+
📂 drizzle-orm/src/mysql-core/ - package with all resources for MySQL database support
9297
9398
📂 examples/ - package with Drizzle ORM usage examples
9499
@@ -118,7 +123,7 @@ Commit message patten
118123
```
119124
Example
120125
```
121-
drizzle-orm-pg: Add groupBy error message
126+
drizzle-orm: [Pg] Add groupBy error message
122127
123128
In specific case, groupBy was responding with unreadable error
124129
...
@@ -145,4 +150,4 @@ List of possible types for branch name
145150
---
146151
Each PR should contain:
147152
- Tests on feature, that was created
148-
- Tests on bugs, that was fixed
153+
- Tests on bugs, that was fixed

README.md

+10-15
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ The ORM main philosophy is "If you know SQL, you know Drizzle ORM". We follow th
1414

1515
Drizzle ORM is being battle-tested on production projects by multiple teams 🚀 Give it a try and let us know if you have any questions or feedback on [Discord](https://discord.gg/yfjTbVXMW4).
1616

17-
### Feature list
17+
## Feature list
1818

1919
- Full type safety
2020
- [Smart automated migrations generation](https://github.com/drizzle-team/drizzle-kit-mirror)
@@ -25,27 +25,22 @@ Drizzle ORM is being battle-tested on production projects by multiple teams 🚀
2525
- Auto-inferring of TS types for DB models for selections and insertions separately
2626
- Zero dependencies
2727

28+
## Database support status
29+
2830
| Database | Support | |
2931
|:------------|:-------:|:---|
30-
| PostgreSQL | |[Docs](https://github.com/drizzle-team/drizzle-orm/tree/main/drizzle-orm-pg)|
31-
| MySQL ||[Docs](https://github.com/drizzle-team/drizzle-orm/tree/main/drizzle-orm-mysql)|
32-
| SQLite ||[Docs](https://github.com/drizzle-team/drizzle-orm/tree/main/drizzle-orm-sqlite)|
32+
| PostgreSQL || [Docs](./drizzle-orm/src/pg-core/README.md)|
33+
| MySQL ||[Docs](./drizzle-orm/src/mysql-core/README.md)|
34+
| SQLite ||[Docs](./drizzle-orm/src/sqlite-core/README.md)|
3335
| DynamoDB || |
3436
| MS SQL || |
3537
| CockroachDB || |
3638

37-
### Installation
39+
## Installation
3840

3941
```bash
40-
# postgresql
41-
npm install drizzle-orm drizzle-orm-pg
42-
npm install -D drizzle-kit
43-
44-
# mysql
45-
npm install drizzle-orm drizzle-orm-mysql
46-
npm install -D drizzle-kit
47-
48-
# sqlite
49-
npm install drizzle-orm drizzle-orm-sqlite
42+
npm install drizzle-orm
5043
npm install -D drizzle-kit
5144
```
45+
46+
See [dialect-specific docs](#database-support-status) for more details.

changelogs/drizzle-orm/0.17.0.md

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# drizzle-orm 0.17.0
2+
3+
## ❗ All ORM packages are now merged into `drizzle-orm`
4+
5+
Starting from release `0.17.0` and onwards, all dialect-specific packages are merged into `drizzle-orm`. Legacy ORM packages will be archived.
6+
7+
### Import paths changes
8+
9+
#### PostgreSQL
10+
11+
- `import { ... } from 'drizzle-orm-pg'` -> `import { ... } from 'drizzle-orm/pg-core'`
12+
- `import { ... } from 'drizzle-orm-pg/node'` -> `import { ... } from 'drizzle-orm/node-postgres'`
13+
- `import { ... } from 'drizzle-orm-pg/neondb'` -> `import { ... } from 'drizzle-orm/neon'`
14+
- `import { ... } from 'drizzle-orm-pg/postgres.js'` -> `import { ... } from 'drizzle-orm/postgres.js'`
15+
16+
#### MySQL
17+
18+
- `import { ... } from 'drizzle-orm-mysql'` -> `import { ... } from 'drizzle-orm/mysql-core'`
19+
- `import { ... } from 'drizzle-orm-mysql/mysql2'` -> `import { ... } from 'drizzle-orm/mysql2'`
20+
21+
#### SQLite
22+
23+
- `import { ... } from 'drizzle-orm-sqlite'` -> `import { ... } from 'drizzle-orm/sqlite-core'`
24+
- `import { ... } from 'drizzle-orm-sqlite/better-sqlite3'` -> `import { ... } from 'drizzle-orm/better-sqlite3'`
25+
- `import { ... } from 'drizzle-orm-sqlite/d1'` -> `import { ... } from 'drizzle-orm/d1'`
26+
- `import { ... } from 'drizzle-orm-sqlite/bun'` -> `import { ... } from 'drizzle-orm/bun-sqlite'`
27+
- `import { ... } from 'drizzle-orm-sqlite/sql.js'` -> `import { ... } from 'drizzle-orm/sql.js'`

docs/custom-types.md

+16-8
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ Each type creation should use 2 classes:
2727
- Builder class is responsible for storing TS return type for specific database datatype and override build function to return ready to use column in table
2828

2929
- `TData` - extends return type for column. Current example will infer string type for current datatype used in schema definition
30+
3031
```typescript
3132
export class PgTextBuilder<TData extends string = string>
3233
extends PgColumnBuilder<
@@ -47,16 +48,18 @@ export class PgTextBuilder<TData extends string = string>
4748
> `$pgColumnBuilderBrand` should be changed and be equal to class name for new data type builder
4849
4950
### Column class explanation - (postgresql text data type example)
51+
5052
---
5153
Column class has set of types/functions, that could be overridden to get needed behavior for custom type
5254

5355
- `TData` - extends return type for column. Current example will infer string type for current datatype used in schema definition
5456

55-
- `getSQLType()` - function, that shows datatype name in database and will be used in migration generation
57+
- `getSQLType()` - function, that shows datatype name in database and will be used in migration generation
5658

57-
- `mapFromDriverValue` - interceptor between database and select query execution. If you want to modify/map/change value for specific data type, it could be done here
59+
- `mapFromDriverValue()` - interceptor between database and select query execution. If you want to modify/map/change value for specific data type, it could be done here
60+
61+
#### Usage example for jsonb type
5862

59-
#### Usage example for jsonb type:
6063
```typescript
6164
override mapToDriverValue(value: TData): string {
6265
return JSON.stringify(value);
@@ -65,7 +68,8 @@ override mapToDriverValue(value: TData): string {
6568

6669
- `mapToDriverValue` - interceptor between user input for insert/update queries and database query. If you want to modify/map/change value for specific data type, it could be done here
6770

68-
#### Usage example for int type:
71+
#### Usage example for int type
72+
6973
```typescript
7074
override mapFromDriverValue(value: number | string): number {
7175
if (typeof value === 'string') {
@@ -76,6 +80,7 @@ override mapFromDriverValue(value: number | string): number {
7680
```
7781

7882
#### Column class example
83+
7984
```typescript
8085
export class PgText<TTableName extends string, TData extends string>
8186
extends PgColumn<ColumnConfig<{ tableName: TTableName; data: TData; driverParam: string }>> {
@@ -105,9 +110,9 @@ export class PgText<TTableName extends string, TData extends string>
105110

106111
</br>
107112

108-
### Full text data type for postgresql looks like:
113+
### Full text data type for PostgreSQL example
109114

110-
For more postgres data type examples you could check [here](https://github.com/drizzle-team/drizzle-orm/tree/main/drizzle-orm-pg/src/columns)
115+
For more postgres data type examples you could check [here](/drizzle-orm/src/pg-core/columns)
111116

112117
```typescript
113118
import { ColumnConfig } from 'drizzle-orm';
@@ -166,12 +171,14 @@ export function text<T extends string = string>(
166171
</br>
167172

168173
### Setting up CITEXT datatype
174+
169175
---
170176
> **Note**
171-
This type is available only with extensions and used for example, just to show how you could setup any data type you want. Extension support will come soon
177+
This type is available only with extensions and used for example, just to show how you could setup any data type you want. Extension support will come soon
172178
</br>
173179

174180
### CITEXT data type example
181+
175182
```typescript
176183
export class PgCITextBuilder<TData extends string = string> extends PgColumnBuilder<
177184
ColumnBuilderConfig<{ data: TData; driverParam: string }>
@@ -203,14 +210,15 @@ export function citext<T extends string = string>(name: string): PgCITextBuilder
203210
```
204211

205212
#### Usage example
213+
206214
```typescript
207215
const table = pgTable('table', {
208216
id: integer('id').primaryKey(),
209217
ciname: citext('ciname')
210218
})
211219
```
212220

213-
# Contributing by adding new custom types in Drizzle ORM
221+
## Contributing by adding new custom types in Drizzle ORM
214222

215223
You could add your created custom data types to Drizzle ORM, so everyone can use it.
216224

0 commit comments

Comments
 (0)