sdispater / orator

The Orator ORM provides a simple yet beautiful ActiveRecord implementation.
https://orator-orm.com
MIT License
1.43k stars 173 forks source link

ColumnDoesNotExist but not actually being referenced #391

Closed ninjrdevelop closed 3 years ago

ninjrdevelop commented 3 years ago

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

alfonsocv12 commented 3 years ago

You just have one migration or have multiple ?

ninjrdevelop commented 3 years ago

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

alfonsocv12 commented 3 years ago

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

ninjrdevelop commented 3 years ago

pycharm64_Kw6v6oW5L5

ninjrdevelop commented 3 years ago

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

alfonsocv12 commented 3 years ago

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'),
    }
}
ninjrdevelop commented 3 years ago

Sadly no luck. pycharm64_aUhgZ347xK

josephmancuso commented 3 years ago

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

ninjrdevelop commented 3 years ago

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

alfonsocv12 commented 3 years ago

@ninjrdevelop Do you have permission_id anywhere on the repository ?

ninjrdevelop commented 3 years ago

Nope.

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

alfonsocv12 commented 3 years ago

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.

ninjrdevelop commented 3 years ago

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