#Database not apply my migrations

30 messages · Page 1 of 1 (latest)

mild hearth
#

In my "showmigrations" : all looks applied:

 [X] 0001_initial                                                                            
 [X] 0002_reproductionperiod_amphibian_reproduction_and_more                                 
 [X] 0003_alter_amphibian_main_mores_and_more```
#

I think it's not a good idea to use "migrate card zero" but i don't see any solutions

raven lake
#

@mild hearth start with checking your migrations files, is there one that adds this field?

#

--fake is otherway around - it doesn't change db

#

if you faked migration before it would be the reason

mild hearth
#

ah, yes, I faked thim

#

how to unfake ?

raven lake
#

then rolling back with --fake should work

mild hearth
#
Operations to perform:
  Apply all migrations: admin, ads, auth, card, contenttypes, documentation, flatpages, member, sessions, sites, thumbnail                                                                                         
Running migrations:
  No migrations to apply.```
raven lake
#

back, so you have to state number

#

which migrations were faked initially?

mild hearth
#

heu..so many command, probably all

#

yeah, I tried many command then all migraitons are faked

raven lake
#

Ok, what is in your database?

#

what matter is how you applied migration first

mild hearth
#
Operations to perform:
  Target specific migration: 0001_initial, from card                                                                                                                                                               
Running migrations:
  Rendering model states... DONE
  Unapplying card.0003_alter_amphibian_main_mores_and_more... OK
  Unapplying card.0002_reproductionperiod_amphibian_reproduction_and_more...Traceback (most recent call last):                                                                                                     
  File "/home/terrariopedia/.production/lib/python3.11/site-packages/django/db/backends/utils.py", line 87, in _execute                                                                                            
    return self.cursor.execute(sql)```
... ```django.db.utils.ProgrammingError: column "reproduction" of relation "card_turtle" does not exist```
raven lake
#

manage.py migrate card 0002
manage.py migrate card 0001 --fake

#

looks like 0002 is either faked or incorrectly applied

mild hearth
#
Operations to perform:
  Target specific migration: 0002_reproductionperiod_amphibian_reproduction_and_more, from card                                                                                        
Running migrations:                        
(.production) terrariopedia@ssh1:~/production$ python manage.py migrate card 0001 --fake     
Operations to perform:
  Target specific migration: 0001_initial, from card                                         
Running migrations:
  Rendering model states... DONE
  Unapplying card.0002_reproductionperiod_amphibian_reproduction_and_more... FAKED
(.production) terrariopedia@ssh1:~/production$```
raven lake
#

now question is in what state is migration 0001

#

again, better connect to your dbms and check tables

mild hearth
#

How can I do that ?

raven lake
#

either manage.py dbshell or use a side tool that can work with your db, like DBeaver, PGadmin, don't remember what are options for SQLite if it's your case

#

dbshell open db console you need lookup syntax that lists tables for your db

mild hearth
#

Ok, I checked table, card_pet.reproduction (the field are miss)

#

to remember, the error is column card_arthropod.reproduction does not exist

mild hearth
#

and it's true

#

lol

mild hearth
#

Hello

#

The problem persist