# Generated by Django 1.11.8.dev20171115030630 on 2017-11-28 13:44
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Author',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=50, verbose_name='author name')),
],
options={
'ordering': ['name'],
'get_latest_by': 'name',
'verbose_name': 'Author',
'verbose_name_plural': 'Authors',
},
),
migrations.CreateModel(
name='Book',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(help_text="book's name", max_length=50, verbose_name='book name')),
('isbn_10', models.CharField(blank=True, db_column='old_isbn_number', db_index=True, help_text='international standart book number (old length 10)', max_length=10, null=True)),
('isbn_13', models.CharField(blank=True, db_index=True, help_text='international standart book number (after 2007 jan 01)', max_length=13, unique=True)),
('language', models.CharField(blank=True, choices=[('PORTUGUESE_BRAZIL', 'Portugu\xeas Brasil'), ('PORTUGUES', 'Portugu\xeas'), ('ENGLISH', 'English'), ('FRANCE', 'France'), ('ESPANISH', 'Espa\xf1ol')], help_text='edition length', max_length=5, null=True)),
],
options={
'ordering': ['name'],
'get_latest_by': 'name',
'verbose_name': 'book',
'verbose_name_plural': 'books',
},
),
migrations.CreateModel(
name='Publisher',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=50, verbose_name='publisher name')),
],
options={
'get_latest_by': 'name',
'ordering': ['name'],
'verbose_name_plural': 'Publishers',
'db_table': '"tbl_litle_name"',
'verbose_name': 'Publiser',
},
),
migrations.AddIndex(
model_name='publisher',
index=models.Index(fields=['name'], name='"tbl_litle__name_408be5_idx'),
),
migrations.AddField(
model_name='book',
name='author',
field=models.ManyToManyField(blank=True, help_text="author's name", null=True, to='testapp.Author'),
),
migrations.AddField(
model_name='book',
name='publisher',
field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='testapp.Publisher'),
),
migrations.AddIndex(
model_name='author',
index=models.Index(fields=['name'], name='testapp_aut_name_02c4bc_idx'),
),
]
The model changed
-----------------
class Publisher(models.Model):
"""
Book's Author - author is a Book's model supplement.
"""
name = models.CharField(verbose_name='publisher name', max_length=50, null=False)
class Meta:
db_table = '"tbl_litle_name"'
get_latest_by = "name"
ordering = ['name', ]
verbose_name = 'Publiser'
verbose_name_plural = 'Publishers'
indexes = [
models.Index(fields=['name', ]),
]
def __unicode__(self):
return self.name
Generated Migration
------------------- # Generated by Django 1.11.8.dev20171115030630 on 2017-11-28 13:36
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
# ... deleted for sanity
migrations.CreateModel(
name='Publisher',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=50, verbose_name='publisher name')),
],
options={
'get_latest_by': 'name',
'ordering': ['name'],
'verbose_name_plural': 'Publishers',
'db_table': '"big_name-with-hyphen-left_in_lowercase"',
'verbose_name': 'Publiser',
},
),
migrations.AddIndex(
model_name='publisher',
index=models.Index(fields=['name'], name='"big_name-w_name_cd0539_idx'), # <===== error `"`
),
# code deleted for sanity
]
MakeMigration ERROR & traceback
--------------------------------
(dj28792) 20171128.Tue11:40:32cadu>/Volumes/p10G/prj/dj_datadictionary_testproject/testproject>
cadu.[563]$python manage.py migrate
System check identified some issues:
WARNINGS:
testapp.Book.author: (fields.W340) null has no effect on ManyToManyField.
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying admin.0002_logentry_remove_auto_add... OK
Applying contenttypes.0002_remove_content_type_name... OK
Applying auth.0002_alter_permission_name_max_length... OK
Applying auth.0003_alter_user_email_max_length... OK
Applying auth.0004_alter_user_username_opts... OK
Applying auth.0005_alter_user_last_login_null... OK
Applying auth.0006_require_contenttypes_0002... OK
Applying auth.0007_alter_validators_add_error_messages... OK
Applying auth.0008_alter_user_username_max_length... OK
Applying sessions.0001_initial... OK
(dj28792) 20171128.Tue11:44:50cadu>/Volumes/p10G/prj/dj_datadictionary_testproject/testproject>
cadu.[564]$python manage.py makemigrations
System check identified some issues:
WARNINGS:
testapp.Book.author: (fields.W340) null has no effect on ManyToManyField.
Migrations for 'testapp':
testproject/testapp/migrations/0001_initial.py
- Create model Author
- Create model Book
- Create model Publisher
- Create index "tbl_litle__name_408be5_idx on field(s) name of model publisher <==========
- Add field author to book
- Add field publisher to book
- Create index testapp_aut_name_02c4bc_idx on field(s) name of model author
(dj28792) 20171128.Tue11:44:55cadu>/Volumes/p10G/prj/dj_datadictionary_testproject/testproject>
cadu.[565]$python manage.py migrate
System check identified some issues:
WARNINGS:
testapp.Book.author: (fields.W340) null has no effect on ManyToManyField.
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions, testapp
Running migrations:
Applying testapp.0001_initial...Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/Users/cadu/Envs/dj28792/src/django/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/Users/cadu/Envs/dj28792/src/django/django/core/management/__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/cadu/Envs/dj28792/src/django/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/cadu/Envs/dj28792/src/django/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/Users/cadu/Envs/dj28792/src/django/django/core/management/commands/migrate.py", line 204, in handle
fake_initial=fake_initial,
File "/Users/cadu/Envs/dj28792/src/django/django/db/migrations/executor.py", line 115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/Users/cadu/Envs/dj28792/src/django/django/db/migrations/executor.py", line 145, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/Users/cadu/Envs/dj28792/src/django/django/db/migrations/executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "/Users/cadu/Envs/dj28792/src/django/django/db/migrations/migration.py", line 129, in apply
operation.database_forwards(self.app_label, schema_editor, old_state, project_state)
File "/Users/cadu/Envs/dj28792/src/django/django/db/migrations/operations/models.py", line 788, in database_forwards
schema_editor.add_index(model, self.index)
File "/Users/cadu/Envs/dj28792/src/django/django/db/backends/base/schema.py", line 331, in add_index
self.execute(index.create_sql(model, self))
File "/Users/cadu/Envs/dj28792/src/django/django/db/backends/base/schema.py", line 120, in execute
cursor.execute(sql, params)
File "/Users/cadu/Envs/dj28792/src/django/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/Users/cadu/Envs/dj28792/src/django/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/Users/cadu/Envs/dj28792/src/django/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/Users/cadu/Envs/dj28792/src/django/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: zero-length delimited identifier at or near """"
LINE 1: CREATE INDEX ""tbl_litle__name_408be5_idx" ON "tbl_litle_nam... <=======================
^
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
even editing the migration manually
... the problem appears again on created CONTRAINT for a PK
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
(dj28792) 20171128.Tue11:45:02cadu>/Volumes/p10G/prj/dj_datadictionary_testproject/testproject>
cadu.[566]$python manage.py migrate
System check identified some issues:
WARNINGS:
testapp.Book.author: (fields.W340) null has no effect on ManyToManyField.
Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions, testapp
Running migrations:
Applying testapp.0001_initial...Traceback (most recent call last):
File "manage.py", line 22, in <module>
execute_from_command_line(sys.argv)
File "/Users/cadu/Envs/dj28792/src/django/django/core/management/__init__.py", line 364, in execute_from_command_line
utility.execute()
File "/Users/cadu/Envs/dj28792/src/django/django/core/management/__init__.py", line 356, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/cadu/Envs/dj28792/src/django/django/core/management/base.py", line 283, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/cadu/Envs/dj28792/src/django/django/core/management/base.py", line 330, in execute
output = self.handle(*args, **options)
File "/Users/cadu/Envs/dj28792/src/django/django/core/management/commands/migrate.py", line 204, in handle
fake_initial=fake_initial,
File "/Users/cadu/Envs/dj28792/src/django/django/db/migrations/executor.py", line 115, in migrate
state = self._migrate_all_forwards(state, plan, full_plan, fake=fake, fake_initial=fake_initial)
File "/Users/cadu/Envs/dj28792/src/django/django/db/migrations/executor.py", line 145, in _migrate_all_forwards
state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial)
File "/Users/cadu/Envs/dj28792/src/django/django/db/migrations/executor.py", line 244, in apply_migration
state = migration.apply(state, schema_editor)
File "/Users/cadu/Envs/dj28792/src/django/django/db/backends/base/schema.py", line 93, in __exit__
self.execute(sql)
File "/Users/cadu/Envs/dj28792/src/django/django/db/backends/base/schema.py", line 120, in execute
cursor.execute(sql, params)
File "/Users/cadu/Envs/dj28792/src/django/django/db/backends/utils.py", line 79, in execute
return super(CursorDebugWrapper, self).execute(sql, params)
File "/Users/cadu/Envs/dj28792/src/django/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
File "/Users/cadu/Envs/dj28792/src/django/django/db/utils.py", line 94, in __exit__
six.reraise(dj_exc_type, dj_exc_value, traceback)
File "/Users/cadu/Envs/dj28792/src/django/django/db/backends/utils.py", line 64, in execute
return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: syntax error at or near "tbl_litle_name"
LINE 1: ...ONSTRAINT "testapp_book_publisher_id_fb33c7ca_fk_"tbl_litle_...
^
^
---------------------------------------------------------------------
Cadu Leite
| Twitter | Medium Blog | Google + |
| @cadu_leite | @cadu_leite | +CarlosLeite |
http://people.python.org.br/