Issue Running Migration against Postgres #1337
-
Good day, I am trying to run a migration against a Postgres DB (the DB is completely fresh, and is connecting when I use a healthcheck) but when I try to run a migration it looks like Knex tries to connect to an SQLite DB instead and then throws an error (because there is no SQLite DB) I get the error when trying to run Here is my model code: import { DateTime } from 'luxon'
import { BaseModel, column } from '@ioc:Adonis/Lucid/Orm'
export default class User extends BaseModel {
@column({ isPrimary: true })
public id: number
@column.dateTime({ autoCreate: true })
public createdAt: DateTime
@column.dateTime({ autoCreate: true, autoUpdate: true })
public updatedAt: DateTime
@column()
public name: String
@column()
public email: String
} And here is the migration code: import BaseSchema from '@ioc:Adonis/Lucid/Schema'
export default class Users extends BaseSchema {
protected tableName = 'users'
public async up () {
this.schema.createTable(this.tableName, (table) => {
table.increments('id')
table.timestamps(true)
// our added fields
table.string('name').notNullable()
table.string('email').unique().notNullable()
})
}
public async down () {
this.schema.dropTable(this.tableName)
}
} The generated DB_CONNECTION=pg
DB_HOST=db
DB_USER=user
DB_PASSWORD=pass
DB_NAME=data
DB_PORT=5432 The ...
db:
image: postgres
restart: unless-stopped
ports:
- 5432:5432
environment:
POSTGRES_PASSWORD: pass
POSTGRES_USER: user
POSTGRES_DB: data When running the migration I initially had an error saying that Knex could not find sqlite3, found it weird but installed the dependency, then ran again, getting the following error:
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Okay, I've found the error, it looks like you need to run a build before running the migration script, going to make a PR to add that to the docs to discuss |
Beta Was this translation helpful? Give feedback.
Okay, I've found the error, it looks like you need to run a build before running the migration script, going to make a PR to add that to the docs to discuss