Estou tendo o seguinte erro quando dou adonis migration:run :
{ error: relation "polo" does not exist
at Connection.parseE (C:\ckinfo\node_modules\pg\lib\connection.js:604:11)
at Connection.parseMessage (C:\ckinfo\node_modules\pg\lib\connection.js:401:19)
at Socket.<anonymous> (C:\ckinfo\node_modules\pg\lib\connection.js:121:22)
at Socket.emit (events.js:198:13)
at addChunk (_stream_readable.js:288:12)
at readableAddChunk (_stream_readable.js:269:11)
at Socket.Readable.push (_stream_readable.js:224:10)
at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
From previous event:
at Client_PG._query (C:\ckinfo\node_modules\knex\lib\dialects\postgres\index.js:260:12)
at Client_PG.query (C:\ckinfo\node_modules\knex\lib\client.js:202:17)
at C:\ckinfo\node_modules\knex\lib\transaction.js:272:21
From previous event:
at Client_PG.trxClient.query (C:\ckinfo\node_modules\knex\lib\transaction.js:269:34)
at Runner.<anonymous> (C:\ckinfo\node_modules\knex\lib\runner.js:146:36)
From previous event:
at Runner.<anonymous> (C:\ckinfo\node_modules\knex\lib\runner.js:213:19)
at runCallback (timers.js:705:18)
at tryOnImmediate (timers.js:676:5)
at processImmediate (timers.js:658:5)
From previous event:
at Runner.queryArray (C:\ckinfo\node_modules\knex\lib\runner.js:212:106)
at C:\ckinfo\node_modules\knex\lib\runner.js:46:23
From previous event:
at Runner.run (C:\ckinfo\node_modules\knex\lib\runner.js:34:31)
at SchemaBuilder.Target.then (C:\ckinfo\node_modules\knex\lib\interface.js:20:43)
name: 'error',
length: 163,
severity: 'ERROR',
code: '42P01',
detail: undefined,
hint: undefined,
position: undefined,
internalPosition: undefined,
internalQuery: undefined,
where: undefined,
schema: undefined,
table: undefined,
column: undefined,
dataType: undefined,
constraint: undefined,
file:
'd:\\pginstaller.auto\\postgres.windows-x64\\src\\backend\\catalog\\namespace.c',
line: '426',
routine: 'RangeVarGetRelidExtended' }
Polo.js 'use strict'
/** @type {typeof import('@adonisjs/lucid/src/Lucid/Model')} */
const Model = use('Model')
class Polo extends Model {
//
departamentos () {
return this.hasMany('App/Models/Departamento')
}
endereco () {
return this.hasOne('App/Models/Endereco')
}
}
module.exports = Polo
MIGRATION DO POLO
'use strict'
/** @type {import('@adonisjs/lucid/src/Schema')} */
const Schema = use('Schema')
class PoloSchema extends Schema {
up () {
this.create('polos', (table) => {
table.increments()
table.string('nome')
table.string('endereco')
table.timestamps()
})
}
down () {
this.drop('polos')
}
}
module.exports = PoloSchema
Departamento.js
'use strict'
/** @type {typeof import('@adonisjs/lucid/src/Lucid/Model')} */
const Model = use('Model')
class Departamento extends Model {
//
telefones() {
return this.hasMany('App/Models/Telefone')
}
polo() {
return this.belongsTo('App/Models/Polo')
}
}
module.exports = Departamento
MIGRATION DO DEPARTAMENTO
'use strict'
/** @type {import('@adonisjs/lucid/src/Schema')} */
const Schema = use('Schema')
class DepartamentoSchema extends Schema {
up () {
this.create('departamentos', (table) => {
table.increments()
table.string('nome')
table.string('gerente')
table.integer('id_polo')
.unsigned()
.references('id')
.inTable('polo')
.onUpdate('CASCADE')
.onDelete('CASCADE')
table.timestamps()
})
}
down () {
this.drop('departamentos')
}
}
module.exports = DepartamentoSchema
Endereco.js
'
use strict'
/** @type {typeof import('@adonisjs/lucid/src/Lucid/Model')} */
const Model = use('Model')
class Endereco extends Model {
polo () {
return this.belongsTo('App/Models/Polo')
}
}
module.exports = Endereco
MIGRATION DO ENDEREÇO
'use strict'
/** @type {import('@adonisjs/lucid/src/Schema')} */
const Schema = use('Schema')
class EnderecoSchema extends Schema {
up () {
this.create('enderecos', (table) => {
table.increments()
table
.integer('polo_id')
.unsigned()
.references('id')
.inTable('polo')
.onUpdate('CASCADE')
.onDelete('CASCADE')
table.string('gix')
table.string('rb')
table.string('vm')
table.timestamps()
})
}
down () {
this.drop('enderecos')
}
}
module.exports = EnderecoSchema