select * from "model_with_soft_deletes" where "id" = $1 and "model_with_soft_deletes"."deleted_at" is null limit $2 - relation "model_with_soft_deletes" does not exist
Closed this issue · 3 comments
❯ migrated database/migrations/1698706721243_user_soft_deletes
Migrated in 1.38 s
❯ error database/seeders/development/0_User
select * from "model_with_soft_deletes" where "email" in ($1, $2, $3, $4, $5) and "model_with_soft_deletes"."deleted_at" is null for update - relation "model_with_soft_deletes" does not exist
Was I supposed to make a model for this? If so, that is not explained in your docs and the code is so heavily abstracted I can't make heads or tails of where "model_with_soft_deletes" is even coming from.
I'm also getting the same error as 16.
// set custom `deletedAt` column name
@column.dateTime({ columnName: 'customDeletedAtColumn' })
public deletedAt?: DateTime | null
public deletedAt?: DateTime | null
produces the following TypeScript error:
Property 'deletedAt' in type 'User' is not assignable to the same property in base type 'LucidRow & { $forceDelete: boolean; deletedAt: DateTime | null; readonly trashed: boolean; $getQueryFor(action: "insert", client: QueryClientContract): InsertQueryBuilderContract<...>; $getQueryFor(action: "update" | ... 1 more ... | "refresh", client: QueryClientContract): ModelQueryBuilderContract<...>; delete(): ...'.
Type 'DateTime | null | undefined' is not assignable to type 'DateTime | null'.
Type 'undefined' is not assignable to type 'DateTime | null'.ts(2416)
(property) User.deletedAt?: DateTime | null | undefined
❯ migrated database/migrations/1698706721243_user_soft_deletes Migrated in 1.38 s ❯ error database/seeders/development/0_User select * from "model_with_soft_deletes" where "email" in ($1, $2, $3, $4, $5) and "model_with_soft_deletes"."deleted_at" is null for update - relation "model_with_soft_deletes" does not exist
Was I supposed to make a model for this? If so, that is not explained in your docs and the code is so heavily abstracted I can't make heads or tails of where "model_with_soft_deletes" is even coming from.
I'm also getting the same error as 16.
// set custom `deletedAt` column name @column.dateTime({ columnName: 'customDeletedAtColumn' }) public deletedAt?: DateTime | null
public deletedAt?: DateTime | null
produces the following TypeScript error:Property 'deletedAt' in type 'User' is not assignable to the same property in base type 'LucidRow & { $forceDelete: boolean; deletedAt: DateTime | null; readonly trashed: boolean; $getQueryFor(action: "insert", client: QueryClientContract): InsertQueryBuilderContract<...>; $getQueryFor(action: "update" | ... 1 more ... | "refresh", client: QueryClientContract): ModelQueryBuilderContract<...>; delete(): ...'. Type 'DateTime | null | undefined' is not assignable to type 'DateTime | null'. Type 'undefined' is not assignable to type 'DateTime | null'.ts(2416) (property) User.deletedAt?: DateTime | null | undefined
I started having this problem when I activated a feature to use global Hook. In this case, my AppProvider.ts file in the boot method has this code
public async boot() {
const { BaseModel } = this.app.container.resolveBinding('Adonis/Lucid/Orm')
const boot = BaseModel.boot
BaseModel.boot = function() {
if (this.booted) return
boot.call(this)
this.before('create', (item) => {
console.log(`[BEFORE] User is creating ${item.constructor.name}`)
})
this.after('create', (item) => {
console.log(`[AFTER] User has created ${item.constructor.name}`)
})
}
}
Without this, the error does not happen.
Remove
@column.dateTime({ columnName: 'customDeletedAtColumn' })
public deletedAt?: DateTime | null,
this is inserted automatic
@TDodgeCo How you use this addon without models? The first paragraph of docs:
This addon adds the functionality to soft deletes Lucid Models
About public deletedAt?: DateTime | null produces the following TypeScript error:
See comment #16 (comment)