Skip to content

Commit

Permalink
Fix actions
Browse files Browse the repository at this point in the history
  • Loading branch information
hyperphoton committed Aug 25, 2023
1 parent e9a479a commit 014f6e1
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 13 deletions.
34 changes: 21 additions & 13 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,20 @@ jobs:
env:
DIALECTOR: postgres
DATABASE_URL: postgres://gorm:gorm@localhost:5432/sharding-test
DATABASE_READ_URL: postgres://gorm:gorm@localhost:5432/sharding-read-test
DATABASE_WRITE_URL: postgres://gorm:gorm@localhost:5432/sharding-write-test
DB_URL: postgres://gorm:gorm@localhost:5432/sharding-test
DB_NOID_URL: postgres://gorm:gorm@localhost:5432/sharding-noid-test
DB_READ_URL: postgres://gorm:gorm@localhost:5432/sharding-read-test
DB_WRITE_URL: postgres://gorm:gorm@localhost:5432/sharding-write-test
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
id: go

- name: Create No ID Database
run: PGPASSWORD=gorm psql -h localhost -U gorm -d sharding-test -c 'CREATE DATABASE "sharding-noid-test";'

- name: Create Read Database
run: PGPASSWORD=gorm psql -h localhost -U gorm -d sharding-test -c 'CREATE DATABASE "sharding-read-test";'

Expand Down Expand Up @@ -93,23 +97,25 @@ jobs:
env:
DIALECTOR: mysql
DATABASE_URL: gorm:gorm@tcp(127.0.0.1:3306)/sharding-test?charset=utf8mb4&parseTime=True&loc=Local
DATABASE_READ_URL: root:gorm@tcp(127.0.0.1:3306)/sharding-read-test?charset=utf8mb4&parseTime=True&loc=Local
DATABASE_WRITE_URL: root:gorm@tcp(127.0.0.1:3306)/sharding-write-test?charset=utf8mb4&parseTime=True&loc=Local
DB_URL: gorm:gorm@tcp(127.0.0.1:3306)/sharding-test?charset=utf8mb4&parseTime=True&loc=Local
DB_NOID_URL: gorm:gorm@tcp(127.0.0.1:3306)/sharding-noid-test?charset=utf8mb4&parseTime=True&loc=Local
DB_READ_URL: root:gorm@tcp(127.0.0.1:3306)/sharding-read-test?charset=utf8mb4&parseTime=True&loc=Local
DB_WRITE_URL: root:gorm@tcp(127.0.0.1:3306)/sharding-write-test?charset=utf8mb4&parseTime=True&loc=Local
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
id: go

- name: Create No ID Database
run: mysqladmin -h 127.0.0.1 -uroot -pgorm create sharding-noid-test

- name: Create Read Database
run: mysqladmin -h 127.0.0.1 -uroot -pgorm create sharding-read-test
#run: mysql -e 'CREATE DATABASE sharding-read-test' -ugorm -pgorm

- name: Create Write Database
run: mysqladmin -h 127.0.0.1 -uroot -pgorm create sharding-write-test
#run: mysql -e 'CREATE DATABASE sharding-write-test' -ugorm -pgorm

- name: Check out code into the Go module directory
uses: actions/checkout@v3
Expand Down Expand Up @@ -148,23 +154,25 @@ jobs:
env:
DIALECTOR: mariadb
DATABASE_URL: gorm:gorm@tcp(127.0.0.1:3306)/sharding-test?charset=utf8mb4&parseTime=True&loc=Local
DATABASE_READ_URL: root:gorm@tcp(127.0.0.1:3306)/sharding-read-test?charset=utf8mb4&parseTime=True&loc=Local
DATABASE_WRITE_URL: root:gorm@tcp(127.0.0.1:3306)/sharding-write-test?charset=utf8mb4&parseTime=True&loc=Local
DB_URL: gorm:gorm@tcp(127.0.0.1:3306)/sharding-test?charset=utf8mb4&parseTime=True&loc=Local
DB_NOID_URL: root:gorm@tcp(127.0.0.1:3306)/sharding-noid-test?charset=utf8mb4&parseTime=True&loc=Local
DB_READ_URL: root:gorm@tcp(127.0.0.1:3306)/sharding-read-test?charset=utf8mb4&parseTime=True&loc=Local
DB_WRITE_URL: root:gorm@tcp(127.0.0.1:3306)/sharding-write-test?charset=utf8mb4&parseTime=True&loc=Local
steps:
- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.20"
id: go

- name: Create No ID Database
run: mysqladmin -h 127.0.0.1 -uroot -pgorm create sharding-noid-test

- name: Create Read Database
run: mysqladmin -h 127.0.0.1 -uroot -pgorm create sharding-read-test
#run: mysql -e 'CREATE DATABASE sharding-read-test' -ugorm -pgorm

- name: Create Write Database
run: mysqladmin -h 127.0.0.1 -uroot -pgorm create sharding-write-test
#run: mysql -e 'CREATE DATABASE sharding-write-test' -ugorm -pgorm

- name: Check out code into the Go module directory
uses: actions/checkout@v3
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ db.Use(sharding.Register(sharding.Config{
}, "orders")
```
### No primary key
If your table doesn't have a primary key, or has a primary key that isn't called `id`, anyway, you don't want to auto-fill the `id` field, then you can set `PrimaryKeyGenerator` to `PKCustom` and have `PrimaryKeyGeneratorFn` return `0`.
## Combining with dbresolver
> 🚨 NOTE: Use dbresolver first.
Expand Down

0 comments on commit 014f6e1

Please sign in to comment.