Skip to content

Commit

Permalink
Merge pull request #101 from koyopro/feature/timezone
Browse files Browse the repository at this point in the history
[accel-record] Add timezone config to docs for mysql
  • Loading branch information
koyopro authored Jan 11, 2025
2 parents fd762d2 + 0f47764 commit d48875d
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion examples/minimal/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ generator custom_generator {

datasource db {
provider = "mysql"
url = "mysql://root:@localhost:3306/accel_test_minimal"
url = "mysql://root:@localhost:3306/accel_test_minimal?timezone=Z"
}

model User {
Expand Down
2 changes: 1 addition & 1 deletion examples/minimal/src/models/_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export const dataSource = {
activeProvider: "mysql",
url: {
fromEnvVar: null,
value: "mysql://root:@localhost:3306/accel_test_minimal",
value: "mysql://root:@localhost:3306/accel_test_minimal?timezone=Z",
},
schemas: [],
} as DataSource;
Expand Down
3 changes: 2 additions & 1 deletion packages/accel-record-core/src/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export interface Config {
* @example
* ```
* sqlite: path.resolve(__dirname, `./prisma/test${process.env.VITEST_POOL_ID}.db`)
* mysql: `mysql://myuser:password@localhost:3306/test_database${process.env.VITEST_POOL_ID}`
* mysql: `mysql://myuser:password@localhost:3306/test_database${process.env.VITEST_POOL_ID}?timezone=Z`
* pg: `postgresql://myuser:password@localhost:5432/test_database${process.env.VITEST_POOL_ID}`
* ```
*/
Expand All @@ -75,6 +75,7 @@ export interface Config {
* user: "root",
* password: "",
* database: `accel_test${process.env.VITEST_POOL_ID}`,
* timezone: "Z",
* }
* }
* ```
Expand Down
4 changes: 2 additions & 2 deletions packages/accel-record/README-ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ initAccelRecord(getDatabaseConfig()).then(() => {
```
```sh
$ export DATABASE_URL="mysql://root:@localhost:3306/accel_test"
$ export DATABASE_URL="mysql://root:@localhost:3306/accel_test?timezone=Z"
$ npx prisma migrate dev
# tsxを使って.tsファイルを実行する例
$ npm i -D tsx
Expand Down Expand Up @@ -854,7 +854,7 @@ beforeAll(async () => {

// Vitestは通常マルチスレッドでテストが行われます。
// 各スレッドで異なるデータベースを利用するためには、VITEST_POOL_IDを利用してデータベースを分離します。
datasourceUrl: `mysql://root:@localhost:3306/accel_test${process.env.VITEST_POOL_ID}`,
datasourceUrl: `mysql://root:@localhost:3306/accel_test${process.env.VITEST_POOL_ID}?timezone=Z`,
});
// initAccelRecordでprismaDirを指定している場合、未反映のマイグレーションを実行することができます。
await Migration.migrate();
Expand Down
4 changes: 2 additions & 2 deletions packages/accel-record/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ initAccelRecord(getDatabaseConfig()).then(() => {
```
```sh
$ export DATABASE_URL="mysql://root:@localhost:3306/accel_test"
$ export DATABASE_URL="mysql://root:@localhost:3306/accel_test?timezone=Z"
$ npx prisma migrate dev
# Example of executing .ts files using tsx
$ npm i -D tsx
Expand Down Expand Up @@ -853,7 +853,7 @@ beforeAll(async () => {

// Vitest usually performs tests in a multi-threaded manner.
// To use different databases in each thread, separate the databases using VITEST_POOL_ID.
datasourceUrl: `mysql://root:@localhost:3306/accel_test${process.env.VITEST_POOL_ID}`,
datasourceUrl: `mysql://root:@localhost:3306/accel_test${process.env.VITEST_POOL_ID}?timezone=Z`,
});
// If prismaDir is specified in initAccelRecord, you can execute pending migrations.
await Migration.migrate();
Expand Down
2 changes: 1 addition & 1 deletion tests/models/_types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -777,7 +777,7 @@ export const dataSource = {
"activeProvider": "mysql",
"url": {
"fromEnvVar": null,
"value": "mysql://root:@localhost:3306/accel_test1"
"value": "mysql://root:@localhost:3306/accel_test1?timezone=Z"
},
"schemas": []
} as DataSource;
Expand Down
4 changes: 2 additions & 2 deletions tests/models/dataSource.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ test("dataSource", () => {
activeProvider: "mysql",
url: {
fromEnvVar: null,
value: "mysql://root:@localhost:3306/accel_test1",
value: "mysql://root:@localhost:3306/accel_test1?timezone=Z",
},
schemas: [],
});
Expand Down Expand Up @@ -51,7 +51,7 @@ test("getDatabaseConfig()", () => {
case "mysql":
expect(config).toMatchObject({
type: "mysql",
datasourceUrl: "mysql://root:@localhost:3306/accel_test1",
datasourceUrl: "mysql://root:@localhost:3306/accel_test1?timezone=Z",
prismaDir: new RegExp("/.+/tests/prisma_mysql"),
});
break;
Expand Down
2 changes: 1 addition & 1 deletion tests/prisma_mysql/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ generator custom_generator {

datasource db {
provider = "mysql"
url = "mysql://root:@localhost:3306/accel_test1"
url = "mysql://root:@localhost:3306/accel_test1?timezone=Z"
}

model User {
Expand Down

0 comments on commit d48875d

Please sign in to comment.