django-cms / djangocms-file

django CMS File is a set of plugins for django CMS that allow you to add files to your site You can either choose a single file or an entire folder.
https://www.django-cms.org/
Other
31 stars 21 forks source link

djangocms_file.0006_migrate_to_filer...Traceback (most recent call last): #26

Closed FabrizioA closed 7 years ago

FabrizioA commented 7 years ago

I'm trying to update djangocmsfile (and alls djangocms* plugins) from version 1.0 to the last one, that use django_filer and easy_thumbnails under the hoods.

When I launch python manage.py migrate, I get this error:

bash File "/Library/Python/2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler raise errorclass, errorvalue django.db.utils.OperationalError: (1060, "Duplicate column name 'file_src_id'")

here my current migrations status: python djangocms_file [X] 0001_initial [X] 0002_auto_20151202_1551 [X] 0003_remove_related_name_for_cmsplugin_ptr [X] 0004_set_related_name_for_cmsplugin_ptr [X] 0005_auto_20160119_1534 [ ] 0006_migrate_to_filer [ ] 0007_adapted_fields [ ] 0008_add_folder [ ] 0009_fixed_null_fields [ ] 0010_removed_null_fields python

in this phase, I'm updating django-cms to 3.4 too.

FinalAngel commented 7 years ago

@FabrizioA might you be able to provide additional details like:

that would help to debug.

FinalAngel commented 7 years ago

@FabrizioA tried it with a clean install using mysql and some example plugins migrating from djangocms-file==1.0 to 2.0.1 and worked perfectly fine.

Your database might eventually be corrupt. Can you provide us additional information as mentioned above?

FabrizioA commented 7 years ago

Hi Angelo,

At this time I have restore a copy backup of my environment. Tomorrow I'll try to replicate the situation in my local environment and post the results here. Thank you. F.

Il giorno 16 nov 2016, alle ore 19:00, Angelo Dini notifications@github.com ha scritto:

@FabrizioA tried it with a clean install using mysql and some example plugins migrating from djangocms-file==1.0 to 2.0.1 and worked perfectly fine.

Your database might eventually be corrupt. Can you provide us additional information as mentioned above?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

FabrizioA commented 7 years ago

Hi, just now I tried to upgrade djangocms-file from version 1.0 to the last one. First I have migrated easy_thumbnails with no problems... then, when I migrate djangocms_file I get:

(env)MacBook-Pro-di-Fabrizio:Ricca_Website fabrizio$ python manage.py migrate Operations to perform: Apply all migrations: filer, djangocms_file, reversion, djangocms_inherit, sessions, admin, djangocms_link, djangocms_text_ckeditor, sites, auth, djangocms_video, menus, contenttypes, djangocms_picture, djangocms_googlemap, core_website, cms, easy_thumbnails, djangocms_snippet Running migrations: Rendering model states... DONE Applying djangocms_file.0006_migrate_to_filer...Traceback (most recent call last): File "manage.py", line 10, in <module> execute_from_command_line(sys.argv) File "/Users/fabrizio/Documents/Progetti/Django_projects/Ricca_Website/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line utility.execute() File "/Users/fabrizio/Documents/Progetti/Django_projects/Ricca_Website/env/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/Users/fabrizio/Documents/Progetti/Django_projects/Ricca_Website/env/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv self.execute(*args, **cmd_options) File "/Users/fabrizio/Documents/Progetti/Django_projects/Ricca_Website/env/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute output = self.handle(*args, **options) File "/Users/fabrizio/Documents/Progetti/Django_projects/Ricca_Website/env/lib/python2.7/site-packages/django/core/management/commands/migrate.py", line 200, in handle executor.migrate(targets, plan, fake=fake, fake_initial=fake_initial) File "/Users/fabrizio/Documents/Progetti/Django_projects/Ricca_Website/env/lib/python2.7/site-packages/django/db/migrations/executor.py", line 92, in migrate self._migrate_all_forwards(plan, full_plan, fake=fake, fake_initial=fake_initial) File "/Users/fabrizio/Documents/Progetti/Django_projects/Ricca_Website/env/lib/python2.7/site-packages/django/db/migrations/executor.py", line 121, in _migrate_all_forwards state = self.apply_migration(state, migration, fake=fake, fake_initial=fake_initial) File "/Users/fabrizio/Documents/Progetti/Django_projects/Ricca_Website/env/lib/python2.7/site-packages/django/db/migrations/executor.py", line 198, in apply_migration state = migration.apply(state, schema_editor) File "/Users/fabrizio/Documents/Progetti/Django_projects/Ricca_Website/env/lib/python2.7/site-packages/django/db/migrations/migration.py", line 123, in apply operation.database_forwards(self.app_label, schema_editor, old_state, project_state) File "/Users/fabrizio/Documents/Progetti/Django_projects/Ricca_Website/env/lib/python2.7/site-packages/django/db/migrations/operations/fields.py", line 62, in database_forwards field, File "/Users/fabrizio/Documents/Progetti/Django_projects/Ricca_Website/env/lib/python2.7/site-packages/django/db/backends/mysql/schema.py", line 50, in add_field super(DatabaseSchemaEditor, self).add_field(model, field) File "/Users/fabrizio/Documents/Progetti/Django_projects/Ricca_Website/env/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 396, in add_field self.execute(sql, params) File "/Users/fabrizio/Documents/Progetti/Django_projects/Ricca_Website/env/lib/python2.7/site-packages/django/db/backends/base/schema.py", line 110, in execute cursor.execute(sql, params) File "/Users/fabrizio/Documents/Progetti/Django_projects/Ricca_Website/env/lib/python2.7/site-packages/django/db/backends/utils.py", line 79, in execute return super(CursorDebugWrapper, self).execute(sql, params) File "/Users/fabrizio/Documents/Progetti/Django_projects/Ricca_Website/env/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) File "/Users/fabrizio/Documents/Progetti/Django_projects/Ricca_Website/env/lib/python2.7/site-packages/django/db/utils.py", line 95, in __exit__ six.reraise(dj_exc_type, dj_exc_value, traceback) File "/Users/fabrizio/Documents/Progetti/Django_projects/Ricca_Website/env/lib/python2.7/site-packages/django/db/backends/utils.py", line 64, in execute return self.cursor.execute(sql, params) File "/Users/fabrizio/Documents/Progetti/Django_projects/Ricca_Website/env/lib/python2.7/site-packages/django/db/backends/mysql/base.py", line 112, in execute return self.cursor.execute(query, args) File "/Library/Python/2.7/site-packages/MySQLdb/cursors.py", line 205, in execute self.errorhandler(self, exc, value) File "/Library/Python/2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler raise errorclass, errorvalue django.db.utils.OperationalError: (1060, "Duplicate column name 'file_src_id'") (env)MacBook-Pro-di-Fabrizio:Ricca_Website fabrizio$

Here djangocms_file show migrations results:

djangocms_file [X] 0001_initial [X] 0002_auto_20151202_1551 [X] 0003_remove_related_name_for_cmsplugin_ptr [X] 0004_set_related_name_for_cmsplugin_ptr [X] 0005_auto_20160119_1534 [ ] 0006_migrate_to_filer [ ] 0007_adapted_fields [ ] 0008_add_folder [ ] 0009_fixed_null_fields [ ] 0010_removed_null_fields

FabrizioA commented 7 years ago

Here the steps I have followed:

This is my requirements.txt (with djangocms-file to update):


Django >= 1.9.11,<1.10 django-cms >= 3.3.1,<3.5 djangocms_text_ckeditor >= 3.0.0 django-reversion == 1.10.1 django-classy-tags >= 0.7.0 django-treebeard >= 4.0 django-sekizai >= 0.8.2 html5lib == 0.999 djangocms-admin-style >= 1.0 django-filer >= 1.2.4 django-mptt >= 0.6 easy_thumbnails >= 1.0 django-polymorphic >= 0.7 djangocms-file djangocms-googlemap == 0.5.1 djangocms-inherit == 0.2.1 djangocms-picture == 1.0.0 djangocms-video == 1.0.0 djangocms-link == 1.8.2 djangocms-snippet


I started from version 1.0.0 of djangocms-file.

step 1: run pip install -r requirements.txt --upgrade to upgrade djangocms-file. step 2: added
..... 'easy_thumbnails', 'filer', 'mptt', ......

to my INSTALLED_APPS (I have added it because I followed the docs to correctly install django-filer)

step 3: run python manage.py migrate easy_thumbnails (it installed just 2 migrations) step 4: run python manage.py migrate (I get the error above).

FabrizioA commented 7 years ago

Here my pip freeze:

Cython==0.23.4 Django==1.9.11 Django-Select2==4.3.2 Fabric==1.10.2 MySQL-python==1.2.5 Pillow==2.7.0 Unidecode==0.04.19 altgraph==0.10.2 bdist-mpkg==0.5.0 bonjour-py==0.3 django-classy-tags==0.8.0 django-cms==3.4.1 django-filer==1.2.5 django-formtools==1.0 django-mptt==0.8.6 django-polymorphic==1.0.2 django-reversion==1.10.1 django-sekizai==0.10.0 django-treebeard==4.0.1 djangocms-admin-style==1.2.6 djangocms-attributes-field==0.1.2 djangocms-file==2.0.1 djangocms-googlemap==0.5.1 djangocms-inherit==0.2.1 djangocms-link==1.8.2 djangocms-picture==1.0.0 djangocms-snippet==1.9.1 djangocms-text-ckeditor==3.3.1 djangocms-video==1.0.0 easy-thumbnails==2.3 ecdsa==0.13 html5lib==0.999 macholib==1.5.1 matplotlib==1.3.1 modulegraph==0.10.4 numpy==1.8.0rc1 paramiko==1.16.0 py2app==0.7.3 pyOpenSSL==0.13.1 pycrypto==2.6.1 pyobjc-core==2.5.1 pyobjc-framework-Accounts==2.5.1 pyobjc-framework-AddressBook==2.5.1 pyobjc-framework-AppleScriptKit==2.5.1 pyobjc-framework-AppleScriptObjC==2.5.1 pyobjc-framework-Automator==2.5.1 pyobjc-framework-CFNetwork==2.5.1 pyobjc-framework-Cocoa==2.5.1 pyobjc-framework-Collaboration==2.5.1 pyobjc-framework-CoreData==2.5.1 pyobjc-framework-CoreLocation==2.5.1 pyobjc-framework-CoreText==2.5.1 pyobjc-framework-DictionaryServices==2.5.1 pyobjc-framework-EventKit==2.5.1 pyobjc-framework-ExceptionHandling==2.5.1 pyobjc-framework-FSEvents==2.5.1 pyobjc-framework-InputMethodKit==2.5.1 pyobjc-framework-InstallerPlugins==2.5.1 pyobjc-framework-InstantMessage==2.5.1 pyobjc-framework-LatentSemanticMapping==2.5.1 pyobjc-framework-LaunchServices==2.5.1 pyobjc-framework-Message==2.5.1 pyobjc-framework-OpenDirectory==2.5.1 pyobjc-framework-PreferencePanes==2.5.1 pyobjc-framework-PubSub==2.5.1 pyobjc-framework-QTKit==2.5.1 pyobjc-framework-Quartz==2.5.1 pyobjc-framework-ScreenSaver==2.5.1 pyobjc-framework-ScriptingBridge==2.5.1 pyobjc-framework-SearchKit==2.5.1 pyobjc-framework-ServiceManagement==2.5.1 pyobjc-framework-Social==2.5.1 pyobjc-framework-SyncServices==2.5.1 pyobjc-framework-SystemConfiguration==2.5.1 pyobjc-framework-WebKit==2.5.1 pyparsing==2.0.1 python-dateutil==1.5 pytz==2013.7 scipy==0.13.0b1 six==1.10.0 virtualenv==1.11.6 wsgiref==0.1.2 xattr==0.6.4 zope.interface==4.1.1

FabrizioA commented 7 years ago

Here my settings.py

` import os gettext = lambda s: s BASE_DIR = os.path.dirname(os.path.dirname(file))

DEBUG = True

ALLOWED_HOSTS = []

ROOT_URLCONF = 'ricca_website.urls'

WSGI_APPLICATION = 'ricca_website.wsgi.application'

LANGUAGE_CODE = 'it'

TIME_ZONE = 'Europe/Rome'

USE_I18N = True

USE_L10N = True

USE_TZ = True

STATIC_ROOT = os.path.join(BASE_DIR, 'static')

STATIC_URL = '/static/'

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')

MEDIA_URL = '/media/'

SITE_ID = 1

MIDDLEWARE_CLASSES = ( 'cms.middleware.utils.ApphookReloadMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', 'cms.middleware.user.CurrentUserMiddleware', 'cms.middleware.page.CurrentPageMiddleware', 'cms.middleware.toolbar.ToolbarMiddleware', 'cms.middleware.language.LanguageCookieMiddleware', 'cms.middleware.utils.ApphookReloadMiddleware' )

TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(BASE_DIR, 'core_website', 'templates'),], 'OPTIONS': { 'context_processors': [ 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', 'django.core.context_processors.i18n', 'django.core.context_processors.debug', 'django.core.context_processors.request', 'django.core.context_processors.media', 'django.core.context_processors.csrf', 'django.core.context_processors.tz', 'django.core.context_processors.static', 'sekizai.context_processors.sekizai', 'cms.context_processors.cms_settings', ], 'loaders': [ 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', 'django.template.loaders.eggs.Loader' ], }, }, ]

INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'djangocms_admin_style', 'django.contrib.admin', 'django.contrib.sites', 'django.contrib.sitemaps', 'django.contrib.staticfiles', 'django.contrib.messages', 'cms', 'treebeard', 'menus', 'sekizai', 'easy_thumbnails', 'filer', 'mptt', 'djangocms_text_ckeditor', 'djangocms_file', 'djangocms_googlemap', 'djangocms_inherit', 'djangocms_picture', 'djangocms_video', 'djangocms_link', 'djangocms_snippet', 'reversion', 'core_website', 'ricca_website' )

LANGUAGES = (

Customize this

('it', gettext('it')),
('en', gettext('en')),

)

CMS_TEMPLATES = (

Customize this

('home.html', 'Home'),
('company.html', 'Azienda'),
('services.html', 'Servizi'),
('work-in-progress.html', 'Work in progress'),
('contacts.html', 'Contatti'),
('customers.html', 'Clienti'),
('single-page.html', "Pagina singola")

)`

FabrizioA commented 7 years ago

I have this problem only in a existing project. If I create a new project I don't have it. Help to fix my current project? :( Maybe in the past some migration file has be merged and now I have this problem with the existing column error...

"/Library/Python/2.7/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler raise errorclass, errorvalue django.db.utils.OperationalError: (1060, "Duplicate column name 'file_src_id'")

INFO I tried to update either djangocms_picture and, when I try to migrate it, I got the same error:

Running migrations: Rendering model states... DONE Applying djangocms_picture.0003_migrate_to_filer...Traceback (most recent call last): django.db.utils.OperationalError: (1060, "Duplicate column name 'picture_id'")

In my opinion the past migrations of django-filer has broken the compatibility with the migrations of djangocms_* plugins that use django-filer... How can I bypass this problem? What can be a robust solution to solve it in a right way?

FabrizioA commented 7 years ago

At this moment I have "apparently" solved my problem by fake-migration the 0006 of djangocms_file and 0003 migration of djangocms_picture and then apply the migration normally...

FinalAngel commented 7 years ago

@FabrizioA thanks for the detailed feedback. I try to reproduce this according to your settings and pip freeze. I'll keep this ticket open until I've done so.

Otherwise I'll advice for further issues to fake migrate those 2.

FabrizioA commented 7 years ago

Hi Angelo,

Maybe you can first install Django filer version 0.9.9 with Djangocms plugins 1.0.0 and then upgrade all.

Bye

Il giorno 17 nov 2016, alle ore 18:37, Angelo Dini notifications@github.com ha scritto:

@FabrizioA thanks for the detailed feedback. I try to reproduce this according to your settings and pip freeze. I'll keep this ticket open until I've done so.

Otherwise I'll advice for further issues to fake migrate those 2.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

FinalAngel commented 7 years ago

@FabrizioA I'll give it a try

FinalAngel commented 7 years ago

@FabrizioA 0006 and 0003 require 0006_auto_20160623_1627 from filer which is in django-filer 1.2.4 and upwards. So when upgrading your project to the latest version of this plugin, you'd need to upgrade / migrate django filer first. That should solve your problem.

I'd adapt the README accordingly to first upgrade filer.