0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

migrate詰まった所

Last updated at Posted at 2020-09-03

ProgrammingError at /admin/world/pref/
リレーション"world_pref"は存在しません
LINE 1: SELECT COUNT(*) AS "__count" FROM "world_pref"

class Pref(models.Model):
name=models.CharField(max_length=10)

def __str__(self):
    return self.name

geodjangodb3=# \dt
リレーション一覧
スキーマ | 名前 | 型 | 所有者
----------+----------------------------+----------+-----------
public | auth_group | テーブル | fumitoshi
public | auth_group_permissions | テーブル | fumitoshi
public | auth_permission | テーブル | fumitoshi
public | auth_user | テーブル | fumitoshi
public | auth_user_groups | テーブル | fumitoshi
public | auth_user_user_permissions | テーブル | fumitoshi
public | django_admin_log | テーブル | fumitoshi
public | django_content_type | テーブル | fumitoshi
public | django_migrations | テーブル | fumitoshi
public | django_session | テーブル | fumitoshi
public | mapapp_evacuation | テーブル | fumitoshi
public | mapapp_information | テーブル | fumitoshi
public | spatial_ref_sys | テーブル | postgres
public | world_evacuation | テーブル | fumitoshi
(14 行)

migrationsは全消しした状態
python manage.py migrate --fake-initial
スキーマ | 名前 | 型 | 所有者
---------+----------------------------+----------+-----------
public | auth_group | テーブル | fumitoshi
public | auth_group_permissions | テーブル | fumitoshi
public | auth_permission | テーブル | fumitoshi
public | auth_user | テーブル | fumitoshi
public | auth_user_groups | テーブル | fumitoshi
public | auth_user_user_permissions | テーブル | fumitoshi
public | django_admin_log | テーブル | fumitoshi
public | django_content_type | テーブル | fumitoshi
public | django_migrations | テーブル | fumitoshi
public | django_session | テーブル | fumitoshi
public | mapapp_evacuation | テーブル | fumitoshi
public | mapapp_information | テーブル | fumitoshi
public | spatial_ref_sys | テーブル | postgres
public | world_evacuation | テーブル | fumitoshi
変化なし

(base) C:\Users\fumi1\Desktop\geogis2>python manage.py migrate --fake world zer
Operations to perform:
Unapply all migrations: world
Running migrations:
Rendering model states... DONE
Unapplying world.0001_initial... FAKED

ファイルの削除
(base) C:\Users\fumi1\Desktop\geogis2>python manage.py makemigrations
Migrations for 'world':
world\migrations\0001_initial.py
- Create model Evacuation
- Create model Pref

python manage.py migrate --fake yourappnamehere
上手くいきませんでした

https://dot-blog.jp/news/how-to-reset-django-migrations/
このサイトどおりにやってもうまくいかず

operations = [
migrations.CreateModel(
name='Evacuation',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('evacuation_site', models.CharField(max_length=255)),
('location', models.CharField(max_length=255)),
('flood', models.CharField(max_length=255)),
('landslides', models.CharField(max_length=255)),
('storm_surge', models.CharField(max_length=255)),
('earthquake', models.CharField(max_length=255)),
('tsunami', models.CharField(max_length=255)),
('massive_fire', models.CharField(max_length=255)),
('inland_flooding', models.CharField(max_length=255)),
('volcanic_phenomena', models.CharField(max_length=255)),
('geom', django.contrib.gis.db.models.fields.PointField(srid=4326)),
],
),
migrations.CreateModel(
name='Pref',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=10)),
],
),
]

このevacuationの部分を消せばよかった

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?