Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no such table: director_vehicle while makemigrations #2

Open
njnu1115 opened this issue Aug 11, 2020 · 6 comments
Open

no such table: director_vehicle while makemigrations #2

njnu1115 opened this issue Aug 11, 2020 · 6 comments

Comments

@njnu1115
Copy link

$python3 manage.py makemigrations
Traceback (most recent call last):
  File "/home/username/.local/lib/python3.6/site-packages/django/db/backends/utils.py", line 86, in _execute
    return self.cursor.execute(sql, params)
  File "/home/username/.local/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 396, in execute
    return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: no such table: director_vehicle

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "manage.py", line 21, in <module>
    main()
  File "manage.py", line 17, in main
    execute_from_command_line(sys.argv)
  File "/home/username/.local/lib/python3.6/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line
    utility.execute()
  File "/home/username/.local/lib/python3.6/site-packages/django/core/management/__init__.py", line 377, in execute
    django.setup()
  File "/home/username/.local/lib/python3.6/site-packages/django/__init__.py", line 24, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/username/.local/lib/python3.6/site-packages/django/apps/registry.py", line 122, in populate
    app_config.ready()
  File "/home/username/ota/uptane-django/uptane_django/director/apps.py", line 28, in ready
    keys_pri['targets'],keys_pub['targets'])
  File "/home/username/ota/uptane-django/uptane_django/director/director.py", line 94, in __init__
    for vin in vins:
  File "/home/username/.local/lib/python3.6/site-packages/django/db/models/query.py", line 276, in __iter__
    self._fetch_all()
  File "/home/username/.local/lib/python3.6/site-packages/django/db/models/query.py", line 1261, in _fetch_all
    self._result_cache = list(self._iterable_class(self))
  File "/home/username/.local/lib/python3.6/site-packages/django/db/models/query.py", line 57, in __iter__
    results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)
  File "/home/username/.local/lib/python3.6/site-packages/django/db/models/sql/compiler.py", line 1151, in execute_sql
    cursor.execute(sql, params)
  File "/home/username/.local/lib/python3.6/site-packages/django/db/backends/utils.py", line 100, in execute
    return super().execute(sql, params)
  File "/home/username/.local/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/home/username/.local/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/home/username/.local/lib/python3.6/site-packages/django/db/backends/utils.py", line 86, in _execute
    return self.cursor.execute(sql, params)
  File "/home/username/.local/lib/python3.6/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/home/username/.local/lib/python3.6/site-packages/django/db/backends/utils.py", line 86, in _execute
    return self.cursor.execute(sql, params)
  File "/home/username/.local/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 396, in execute
    return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such table: director_vehicle
@njnu1115
Copy link
Author

If I manually create a table in db.sqlite3 with name "director_vehicle" and key "identifier", makemigrations passed but migrate will fail with table "director_vehicle" already exists

`python3 manage.py migrate
Creating '/home/username/ota/uptane-django/image_repo'
Creating '/home/username/ota/uptane-django/image_repo/metadata.staged'
Creating '/home/username/ota/uptane-django/image_repo/targets'
'timestamp.json' expires Wed Aug 12 03:55:37 2020 (UTC).
0.9999652777777778 day(s) until it expires.
Operations to perform:
Apply all migrations: admin, auth, contenttypes, director, image, sessions
Running migrations:
Applying director.0001_initial...Traceback (most recent call last):
File "/home/username/.local/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql)
File "/home/username/.local/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 394, in execute
return Database.Cursor.execute(self, query)
sqlite3.OperationalError: table "director_vehicle" already exists

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "manage.py", line 21, in
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/home/username/.local/lib/python3.6/site-packages/django/core/management/init.py", line 401, in execute_from_command_line
utility.execute()
File "/home/username/.local/lib/python3.6/site-packages/django/core/management/init.py", line 395, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/username/.local/lib/python3.6/site-packages/django/core/management/base.py", line 328, in run_from_argv
self.execute(*args, **cmd_options)
File "/home/username/.local/lib/python3.6/site-packages/django/core/management/base.py", line 369, in execute
output = self.handle(*args, **options)
File "/home/username/.local/lib/python3.6/site-packages/django/core/management/base.py", line 83, in wrapped
res = handle_func(*args, **kwargs)
File "/home/username/.local/lib/python3.6/site-packages/django/core/management/commands/migrate.py", line 233, in handle
fake_initial=fake_initial,
File "/home/username/.local/lib/python3.6/site-packages/django/db/migrations/executor.py", line 117, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/home/username/.local/lib/python3.6/site-packages/django/db/migrations/executor.py", line 147, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/home/username/.local/lib/python3.6/site-packages/django/db/migrations/executor.py", line 245, in apply_migration
state = migration.apply(state, schema_editor)
File "/home/username/.local/lib/python3.6/site-packages/django/db/migrations/migration.py", line 124, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/home/username/.local/lib/python3.6/site-packages/django/db/migrations/operations/models.py", line 92, in database_forwards
schema_editor.create_model(model)
File "/home/username/.local/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 324, in create_model
self.execute(sql, params or None)
File "/home/username/.local/lib/python3.6/site-packages/django/db/backends/base/schema.py", line 142, in execute
cursor.execute(sql, params)
File "/home/username/.local/lib/python3.6/site-packages/django/db/backends/utils.py", line 100, in execute
return super().execute(sql, params)
File "/home/username/.local/lib/python3.6/site-packages/django/db/backends/utils.py", line 68, in execute
return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
File "/home/username/.local/lib/python3.6/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
return executor(sql, params, many, context)
File "/home/username/.local/lib/python3.6/site-packages/django/db/backends/utils.py", line 86, in _execute
return self.cursor.execute(sql, params)
File "/home/username/.local/lib/python3.6/site-packages/django/db/utils.py", line 90, in exit
raise dj_exc_value.with_traceback(traceback) from exc_value
File "/home/username/.local/lib/python3.6/site-packages/django/db/backends/utils.py", line 84, in _execute
return self.cursor.execute(sql)
File "/home/username/.local/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 394, in execute
return Database.Cursor.execute(self, query)
django.db.utils.OperationalError: table "director_vehicle" already exists`

@frankie-zeng
Copy link
Owner

Yeah, this trouble existed. workaround way: Comment uptane_django/director/director.py line89-92 uncomment line 93 and run.
right now the table has created. then checkout the code.

@pyh0603
Copy link

pyh0603 commented Nov 15, 2022

Yeah, this trouble existed. workaround way: Comment uptane_django/director/director.py line89-92 uncomment line 93 and run. right now the table has created. then checkout the code.

你好,我也遇到了同样的问题:django.db.utils.OperationalError: no such table: director_vehicle
我参照你的说明修改文件:uptane_django/director/director.py ,但是文件内容如下:
87 self.vehicle_repositories = dict()
88
89 try:
90 vins=inventory.get_all_registed_vin()
91 except:
92 pass
93 vins=[]
94 for vin in vins:
95 # inventory.load_manifests_dict(vin.identifier)
96 self.create_director_repo_for_vehicle(vin.identifier)
97 repo=self.vehicle_repositories[vin.identifier]

当我注释掉89-92行,不注释93行时,运行,报如下错误:
Traceback (most recent call last):
File "manage.py", line 21, in
main()
File "manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/home/pyh/.local/lib/python3.8/site-packages/django/core/management/init.py", line 401, in execute_from_command_line
utility.execute()
File "/home/pyh/.local/lib/python3.8/site-packages/django/core/management/init.py", line 377, in execute
django.setup()
File "/home/pyh/.local/lib/python3.8/site-packages/django/init.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/pyh/.local/lib/python3.8/site-packages/django/apps/registry.py", line 122, in populate
app_config.ready()
File "/home/pyh/develop/ota_server/uptane-django/uptane_django/director/apps.py", line 9, in ready
import director.director as director
File "/home/pyh/develop/ota_server/uptane-django/uptane_django/director/director.py", line 93
vins=[]
^
IndentationError: unexpected indent

请问,该如何解决此问题呢?

@knitin777
Copy link

Yeah, this trouble existed. workaround way: Comment uptane_django/director/director.py line89-92 uncomment line 93 and run. right now the table has created. then checkout the code.
Can you please let us know which exactly line has to be commented and which has to be uncommented?

89 try:
90 vins=inventory.get_all_registed_vin()
91 except:
92 pass
93 vins=[]

@knitin777
Copy link

Yeah, this trouble existed. workaround way: Comment uptane_django/director/director.py line89-92 uncomment line 93 and run. right now the table has created. then checkout the code.
Can you please let us know which exactly line has to be commented and which has to be uncommented?

89 try: 90 vins=inventory.get_all_registed_vin() 91 except: 92 pass 93 vins=[]

This works!

@knitin777
Copy link

Yeah, this trouble existed. workaround way: Comment uptane_django/director/director.py line89-92 uncomment line 93 and run. right now the table has created. then checkout the code.

你好,我也遇到了同样的问题:django.db.utils.OperationalError: no such table: director_vehicle 我参照你的说明修改文件:uptane_django/director/director.py ,但是文件内容如下: 87 self.vehicle_repositories = dict() 88 89 try: 90 vins=inventory.get_all_registed_vin() 91 except: 92 pass 93 vins=[] 94 for vin in vins: 95 # inventory.load_manifests_dict(vin.identifier) 96 self.create_director_repo_for_vehicle(vin.identifier) 97 repo=self.vehicle_repositories[vin.identifier]

当我注释掉89-92行,不注释93行时,运行,报如下错误: Traceback (most recent call last): File "manage.py", line 21, in main() File "manage.py", line 17, in main execute_from_command_line(sys.argv) File "/home/pyh/.local/lib/python3.8/site-packages/django/core/management/init.py", line 401, in execute_from_command_line utility.execute() File "/home/pyh/.local/lib/python3.8/site-packages/django/core/management/init.py", line 377, in execute django.setup() File "/home/pyh/.local/lib/python3.8/site-packages/django/init.py", line 24, in setup apps.populate(settings.INSTALLED_APPS) File "/home/pyh/.local/lib/python3.8/site-packages/django/apps/registry.py", line 122, in populate app_config.ready() File "/home/pyh/develop/ota_server/uptane-django/uptane_django/director/apps.py", line 9, in ready import director.director as director File "/home/pyh/develop/ota_server/uptane-django/uptane_django/director/director.py", line 93 vins=[] ^ IndentationError: unexpected indent

请问,该如何解决此问题呢?

Please check indentetion
vins=[]
for vin in vins:
both should be in same line

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants