Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: adonisjs/lucid
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v18.3.0
Choose a base ref
...
head repository: adonisjs/lucid
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v18.4.0
Choose a head ref
  • 9 commits
  • 12 files changed
  • 3 contributors

Commits on May 4, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    8955b12 View commit details

Commits on May 22, 2023

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    9bf8f24 View commit details
  2. Copy the full SHA
    05f28e4 View commit details
  3. chore: update dependencies

    thetutlage committed May 22, 2023
    Copy the full SHA
    f59ef9e View commit details
  4. style: format source code

    thetutlage committed May 22, 2023
    Copy the full SHA
    92f0de6 View commit details
  5. Copy the full SHA
    ecb7d77 View commit details
  6. Copy the full SHA
    0e51132 View commit details
  7. Copy the full SHA
    5562cef View commit details
  8. chore(release): 18.4.0

    thetutlage committed May 22, 2023
    Copy the full SHA
    7e01150 View commit details
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -99,7 +99,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [14, 16, 18]
node-version: [16, 18]
services:
mssql:
image: mcr.microsoft.com/mssql/server:2019-latest
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -37,7 +37,7 @@
<sub>Built with ❤︎ by <a href="https://twitter.com/AmanVirk1">Harminder Virk</a>
</div>

[gh-workflow-image]: https://img.shields.io/github/workflow/status/adonisjs/lucid/test?style=for-the-badge
[gh-workflow-image]: https://img.shields.io/github/actions/workflow/status/adonisjs/lucid/test.yml?style=for-the-badge
[gh-workflow-url]: https://github.com/adonisjs/lucid/actions/workflows/test.yml "Github action"

[typescript-image]: https://img.shields.io/badge/Typescript-294E80.svg?style=for-the-badge&logo=typescript
3 changes: 3 additions & 0 deletions adonis-typings/migrator.ts
Original file line number Diff line number Diff line change
@@ -20,12 +20,14 @@ declare module '@ioc:Adonis/Lucid/Migrator' {
direction: 'up'
connectionName?: string
dryRun?: boolean
disableLocks?: boolean
}
| {
direction: 'down'
batch?: number
connectionName?: string
dryRun?: boolean
disableLocks?: boolean
}

/**
@@ -53,6 +55,7 @@ declare module '@ioc:Adonis/Lucid/Migrator' {
*/
export interface MigratorContract extends EventEmitter {
dryRun: boolean
disableLocks: boolean
version: number
direction: 'up' | 'down'
status: 'completed' | 'skipped' | 'pending' | 'error'
10 changes: 10 additions & 0 deletions commands/Migration/Fresh.ts
Original file line number Diff line number Diff line change
@@ -50,6 +50,12 @@ export default class Refresh extends BaseCommand {
@flags.boolean({ description: 'Drop all custom types (Postgres only)' })
public dropTypes: boolean

/**
* Disable advisory locks
*/
@flags.boolean({ description: 'Disable locks acquired to run migrations safely' })
public disableLocks: boolean

/**
* Converting command properties to arguments
*/
@@ -63,6 +69,10 @@ export default class Refresh extends BaseCommand {
args.push(`--connection="${this.connection}"`)
}

if (this.disableLocks) {
args.push('--disable-locks')
}

return args
}

10 changes: 10 additions & 0 deletions commands/Migration/Refresh.ts
Original file line number Diff line number Diff line change
@@ -44,6 +44,12 @@ export default class Refresh extends BaseCommand {
@flags.boolean({ description: 'Run seeders' })
public seed: boolean

/**
* Disable advisory locks
*/
@flags.boolean({ description: 'Disable locks acquired to run migrations safely' })
public disableLocks: boolean

/**
* Converting command properties to arguments
*/
@@ -61,6 +67,10 @@ export default class Refresh extends BaseCommand {
args.push('--dry-run')
}

if (this.disableLocks) {
args.push('--disable-locks')
}

return args
}

10 changes: 10 additions & 0 deletions commands/Migration/Reset.ts
Original file line number Diff line number Diff line change
@@ -38,6 +38,12 @@ export default class Reset extends BaseCommand {
@flags.boolean({ description: 'Do not run actual queries. Instead view the SQL output' })
public dryRun: boolean

/**
* Disable advisory locks
*/
@flags.boolean({ description: 'Disable locks acquired to run migrations safely' })
public disableLocks: boolean

/**
* Converting command properties to arguments
*/
@@ -55,6 +61,10 @@ export default class Reset extends BaseCommand {
args.push('--dry-run')
}

if (this.disableLocks) {
args.push('--disable-locks')
}

return args
}

7 changes: 7 additions & 0 deletions commands/Migration/Rollback.ts
Original file line number Diff line number Diff line change
@@ -57,6 +57,12 @@ export default class Migrate extends MigrationsBase {
@flags.boolean({ description: 'A compact single-line output' })
public compactOutput: boolean = false

/**
* Disable advisory locks
*/
@flags.boolean({ description: 'Disable locks acquired to run migrations safely' })
public disableLocks: boolean

/**
* Instantiating the migrator instance
*/
@@ -69,6 +75,7 @@ export default class Migrate extends MigrationsBase {
connectionName: this.connection,
batch: this.batch,
dryRun: this.dryRun,
disableLocks: this.disableLocks,
})
}

7 changes: 7 additions & 0 deletions commands/Migration/Run.ts
Original file line number Diff line number Diff line change
@@ -48,6 +48,12 @@ export default class Migrate extends MigrationsBase {
@flags.boolean({ description: 'A compact single-line output' })
public compactOutput: boolean = false

/**
* Disable advisory locks
*/
@flags.boolean({ description: 'Disable locks acquired to run migrations safely' })
public disableLocks: boolean

/**
* Instantiating the migrator instance
*/
@@ -59,6 +65,7 @@ export default class Migrate extends MigrationsBase {
direction: 'up',
connectionName: this.connection,
dryRun: this.dryRun,
disableLocks: this.disableLocks,
})
}

60 changes: 30 additions & 30 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adonisjs/lucid",
"version": "18.3.0",
"version": "18.4.0",
"description": "SQL ORM built on top of Active Record pattern",
"main": "build/providers/DatabaseProvider.js",
"files": [
@@ -46,17 +46,17 @@
},
"homepage": "https://github.com/adonisjs/lucid#readme",
"dependencies": {
"@faker-js/faker": "^7.6.0",
"@faker-js/faker": "^8.0.1",
"@poppinss/hooks": "^5.0.3",
"@poppinss/utils": "^5.0.0",
"fast-deep-equal": "^3.1.3",
"igniculus": "^1.5.0",
"knex": "^2.3.0",
"knex-dynamic-connection": "^3.0.0",
"luxon": "^3.1.0",
"knex": "^2.4.2",
"knex-dynamic-connection": "^3.0.1",
"luxon": "^3.3.0",
"macroable": "^7.0.2",
"pretty-hrtime": "^1.0.3",
"qs": "^6.11.0",
"qs": "^6.11.2",
"slash": "^3.0.0",
"tarn": "^3.0.2"
},
@@ -65,44 +65,44 @@
},
"devDependencies": {
"@adonisjs/ace": "^11.3.1",
"@adonisjs/core": "^5.8.9",
"@adonisjs/core": "^5.9.0",
"@adonisjs/mrm-preset": "^5.0.3",
"@adonisjs/repl": "^3.1.11",
"@adonisjs/require-ts": "^2.0.13",
"@adonisjs/sink": "^5.4.2",
"@adonisjs/validator": "^12.4.1",
"@japa/assert": "^1.3.6",
"@japa/run-failed-tests": "^1.1.0",
"@japa/runner": "^2.2.2",
"@japa/spec-reporter": "^1.3.2",
"@adonisjs/sink": "^5.4.3",
"@adonisjs/validator": "^12.4.2",
"@japa/assert": "^1.4.1",
"@japa/run-failed-tests": "^1.1.1",
"@japa/runner": "^2.5.1",
"@japa/spec-reporter": "^1.3.3",
"@poppinss/dev-utils": "^2.0.3",
"@types/luxon": "^3.1.0",
"@types/node": "^18.11.9",
"@types/luxon": "^3.3.0",
"@types/node": "^20.2.3",
"@types/pluralize": "0.0.29",
"@types/qs": "^6.9.7",
"better-sqlite3": "^7.6.2",
"chance": "^1.1.9",
"commitizen": "^4.2.5",
"better-sqlite3": "^8.4.0",
"chance": "^1.1.11",
"commitizen": "^4.3.0",
"copyfiles": "^2.4.1",
"cross-env": "^7.0.3",
"cz-conventional-changelog": "^3.3.0",
"del-cli": "^5.0.0",
"dotenv": "^16.0.3",
"eslint": "^8.28.0",
"eslint-config-prettier": "^8.5.0",
"eslint": "^8.41.0",
"eslint-config-prettier": "^8.8.0",
"eslint-plugin-adonis": "^2.1.1",
"eslint-plugin-prettier": "^4.2.1",
"fs-extra": "^10.1.0",
"github-label-sync": "^2.2.0",
"husky": "^8.0.2",
"mrm": "^4.1.13",
"mysql2": "^2.3.3",
"np": "^7.6.2",
"pg": "^8.8.0",
"prettier": "^2.7.1",
"fs-extra": "^11.1.1",
"github-label-sync": "^2.3.1",
"husky": "^8.0.3",
"mrm": "^4.1.14",
"mysql2": "^3.3.1",
"np": "^7.7.0",
"pg": "^8.11.0",
"prettier": "^2.8.8",
"reflect-metadata": "^0.1.13",
"sqlite3": "^5.1.2",
"tedious": "^15.1.2",
"sqlite3": "^5.1.6",
"tedious": "^16.1.0",
"typescript": "4.8.4"
},
"publishConfig": {
6 changes: 3 additions & 3 deletions src/Bindings/Validator.ts
Original file line number Diff line number Diff line change
@@ -42,7 +42,7 @@ class DbRowCheck {
constructor(
private ruleName: 'exists' | 'unique',
private database: DatabaseContract,
private helpers: typeof validatorStatic['helpers']
private helpers: (typeof validatorStatic)['helpers']
) {}

/**
@@ -224,7 +224,7 @@ export function extendValidator(
*/
const existsChecker = new DbRowCheck('exists', database, validator.helpers)

validator.rule<ReturnType<typeof existsChecker['compile']>>(
validator.rule<ReturnType<(typeof existsChecker)['compile']>>(
'exists',
async (value, compiledOptions, options) => {
try {
@@ -252,7 +252,7 @@ export function extendValidator(
*/
const uniqueChecker = new DbRowCheck('unique', database, validator.helpers)

validator.rule<ReturnType<typeof existsChecker['compile']>>(
validator.rule<ReturnType<(typeof existsChecker)['compile']>>(
'unique',
async (value, compiledOptions, options) => {
try {
9 changes: 7 additions & 2 deletions src/Migrator/index.ts
Original file line number Diff line number Diff line change
@@ -80,6 +80,11 @@ export class Migrator extends EventEmitter implements MigratorContract {
*/
public dryRun: boolean = !!this.options.dryRun

/**
* Disable advisory locks
*/
public disableLocks: boolean = !!this.options.disableLocks

/**
* An array of files we have successfully migrated. The files are
* collected regardless of `up` or `down` methods
@@ -252,7 +257,7 @@ export class Migrator extends EventEmitter implements MigratorContract {
* to the real execution cycle
*/
private async acquireLock() {
if (!this.client.dialect.supportsAdvisoryLocks) {
if (!this.client.dialect.supportsAdvisoryLocks || this.disableLocks) {
return
}

@@ -268,7 +273,7 @@ export class Migrator extends EventEmitter implements MigratorContract {
* `Mysql`, `PostgreSQL` and `MariaDb` for now.
*/
private async releaseLock() {
if (!this.client.dialect.supportsAdvisoryLocks) {
if (!this.client.dialect.supportsAdvisoryLocks || this.disableLocks) {
return
}

2 changes: 1 addition & 1 deletion templates/database.txt
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ import Env from '@ioc:Adonis/Core/Env'
{{#sqlite}}
import Application from '@ioc:Adonis/Core/Application'
{{/sqlite}}
import { DatabaseConfig } from '@ioc:Adonis/Lucid/Database'
import type { DatabaseConfig } from '@ioc:Adonis/Lucid/Database'

const databaseConfig: DatabaseConfig = {
/*