sdispater / orator

The Orator ORM provides a simple yet beautiful ActiveRecord implementation.

Home Page:https://orator-orm.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ColumnDoesNotExist but not actually being referenced

ninjrdevelop opened this issue · comments

Hi guys, have a strange issue I'm hoping for some assistance on.

I have a migration: https://gist.github.com/ninjrdevelop/dd5f2715eeef30aca3308042880729a3

When I run it, I get the error:

[ColumnDoesNotExist]
  Column "permission_id" does not exist on table "users".

migrate -vvv: https://gist.github.com/ninjrdevelop/6bb795742e1f736ff38360a3c89faa8a
migrate --pretend: https://gist.github.com/ninjrdevelop/b1915ac62ae66f2f3d17052b3e04d864

Image of table structure attached.

Any thoughts? There's no reference to permission_id anywhere in this project.
vivaldi_jdRDBd1nMR

You just have one migration or have multiple ?

I have quite a few migrations, as the app has expanded over time. The migration in question was the only one running at the time, as everything else had been sorted previously. None of these have 'permission_id' in them.
pycharm64_PItWHzjGBW

Can you run the migrate:status command and take a screenshot of the response ?

Wierd thing is that if I go manually add a 'permission_id' field to the 'users' table, this migration runs perfectly......

Okay i believe the problem is with the db.py file so try using the orator cli alone, I have this configuration for the migrations most of the time.

Screen Shot 2021-03-25 at 16 39 55

with this file arrangement on top, the command is like this

orator migrate -c orator_config.py

the orator_config.py has this in it

from env import os

DATABASES = {
    'mysql': {
        'driver': 'mysql',
        'host': os.environ.get('host'),
        'database': os.environ.get('database'),
        'user': os.environ.get('user'),
        'password': os.environ.get('password'),
        'port': os.environ.get('port'),
        'prefix': os.environ.get('prefix'),
    }
}

Sadly no luck.
pycharm64_aUhgZ347xK

Could the issue be related to the fact that you have an orator.py file? This is going to conflict anytime you try to use orator because of python import hierarchy. Try changing the name of that orator.py file to something else

Touché, didn't think of that. It's now orator_config.py, and still the same result as my last image.

@ninjrdevelop Do you have permission_id anywhere on the repository ?

Nope.

Just used Find in Folder in Sublime Text and got:
Searching 4887 files for "permission_id"
0 matches

Jajajaja we're working with a severe case of Magic (programing), I'm out of ideas, but pretty interested to know how you will fix this.

Haha, yeah that's what I figured.
I had to keep going, so I just bypassed the issue by actually adding a permission_id field to the user table so it wouldn't complain any longer.
Thanks for the help @alfonsocv12