Skip to content

Commit

Permalink
WIP migrate to latest sequelize-v7
Browse files Browse the repository at this point in the history
  • Loading branch information
Hornwitser committed Oct 30, 2024
1 parent 6cf36c7 commit 285a9ad
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 13 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ jobs:
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: /bin/bash ./dev/prepare-ci.sh
- name: Execute SSCCE
run: yarn run _test
Expand All @@ -45,7 +44,6 @@ jobs:
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: /bin/bash ./dev/prepare-ci.sh
- run: yarn start-postgres-${{ matrix.postgres-version }}
- name: Execute SSCCE
Expand All @@ -66,7 +64,6 @@ jobs:
- uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8 # v4.0.2
with:
node-version: ${{ matrix.node-version }}
cache: yarn
- run: /bin/bash ./dev/prepare-ci.sh
- run: yarn start-${{ matrix.dialect }}-${{ matrix.database-version }}
- name: Execute SSCCE
Expand Down
2 changes: 1 addition & 1 deletion dev/create-sequelize-instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export function createSequelize6Instance(options?: Sequelize6Options): Sequelize
return new Sequelize6(wrapOptions(options));
}

export function createSequelize7Instance(options?: Sequelize7Options): Sequelize7 {
export function createSequelize7Instance(options?: Sequelize7Options<any>): Sequelize7 {
// not compatible with node 10
const { Sequelize: Sequelize7Constructor } = require('@sequelize/core');
// @ts-expect-error -- wrapOptions expect sequelize 6.
Expand Down
12 changes: 6 additions & 6 deletions dev/prepare-ci.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
yarn install --ignore-engines;

if [ "$DIALECT" = "postgres" ]; then
yarn add pg@^8 pg-hstore@^2 pg-types@^2 --ignore-engines;
yarn add pg@^8 pg-hstore@^2 pg-types@^2 @sequelize/postgres --ignore-engines;
elif [ "$DIALECT" = "postgres-native" ]; then
yarn add pg@^8 pg-hstore@^2 pg-types@^2 pg-native --ignore-engines;
yarn add pg@^8 pg-hstore@^2 pg-types@^2 pg-native @sequelize/postgres --ignore-engines;
elif [ "$DIALECT" = "mysql" ]; then
yarn add mysql2@^2 --ignore-engines;
yarn add mysql2@^2 @sequelize/mysql --ignore-engines;
elif [ "$DIALECT" = "mariadb" ]; then
yarn add mariadb@^2 --ignore-engines;
yarn add mariadb@^2 @sequelize/mariadb --ignore-engines;
elif [ "$DIALECT" = "sqlite" ]; then
yarn add sqlite3@^5 --ignore-engines;
yarn add sqlite3@^5 @sequelize/sqlite --ignore-engines;
elif [ "$DIALECT" = "mssql" ]; then
yarn add tedious@^8 --ignore-engines;
yarn add tedious@^8 @sequelize/mssql --ignore-engines;
fi
2 changes: 1 addition & 1 deletion dev/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ async function wrappedRun() {
}

try {
await run();
await run(process.env.DIALECT);
} catch (error) {
logRed('Sequelize 7 test failed');
logRed(error);
Expand Down
5 changes: 3 additions & 2 deletions src/sscce-sequelize-7.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CreationOptional, DataTypes, InferAttributes, InferCreationAttributes, Model } from '@sequelize/core';
import { CreationOptional, DataTypes, DialectName, InferAttributes, InferCreationAttributes, Model } from '@sequelize/core';
import { Attribute, PrimaryKey } from '@sequelize/core/decorators-legacy';
import { createSequelize7Instance } from '../dev/create-sequelize-instance';
import { expect } from 'chai';
Expand All @@ -10,10 +10,11 @@ export const testingOnDialects = new Set(['mssql', 'sqlite', 'mysql', 'mariadb',
// You can delete this file if you don't want your SSCCE to be tested against Sequelize 7

// Your SSCCE goes inside this function.
export async function run() {
export async function run(dialect: DialectName) {
// This function should be used instead of `new Sequelize()`.
// It applies the config for your SSCCE to work on CI.
const sequelize = createSequelize7Instance({
dialect,
logQueryParameters: true,
benchmark: true,
define: {
Expand Down

0 comments on commit 285a9ad

Please sign in to comment.