{"action":"created","issue":{"url":"https://api.github.com/repos/alex/django-taggit/issues/285","labels_url":"https://api.github.com/repos/alex/django-taggit/issues/285/labels{/name}","comments_url":"https://api.github.com/repos/alex/django-taggit/issues/285/comments","events_url":"https://api.github.com/repos/alex/django-taggit/issues/285/events","html_url":"https://github.com/alex/django-taggit/issues/285","id":53507517,"number":285,"title":"Migration failure with Django 1.7.2 and sqlite database when using a through model.","user":{"login":"lpomfrey","id":1630717,"avatar_url":"https://avatars.githubusercontent.com/u/1630717?v=3","gravatar_id":"","url":"https://api.github.com/users/lpomfrey","html_url":"https://github.com/lpomfrey","followers_url":"https://api.github.com/users/lpomfrey/followers","following_url":"https://api.github.com/users/lpomfrey/following{/other_user}","gists_url":"https://api.github.com/users/lpomfrey/gists{/gist_id}","starred_url":"https://api.github.com/users/lpomfrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lpomfrey/subscriptions","organizations_url":"https://api.github.com/users/lpomfrey/orgs","repos_url":"https://api.github.com/users/lpomfrey/repos","events_url":"https://api.github.com/users/lpomfrey/events{/privacy}","received_events_url":"https://api.github.com/users/lpomfrey/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":21,"created_at":"2015-01-06T11:51:20Z","updated_at":"2015-02-27T21:24:42Z","closed_at":null,"body":"I'm not entirely sure whether this is an issue with taggit or Django itself, but since I can only reproduce it with taggit I'm reporting it here. Feel free to close as a Django issue if you think this isn't anything to do with taggit.\r\n\r\nWhen using a through model with taggit and Django 1.7.2, migrations always fail with an OperationalError. This only occurs (as far as I know) with the sqlite backend, PostgreSQL, at least, is fine.\r\n\r\n**To reproduce**\r\n\r\nCreate a simple project with an app with the following `models.py`\r\n\r\n    from django.db import models\r\n    from taggit.managers import TaggableManager\r\n    from taggit.models import TaggedItemBase\r\n    \r\n    \r\n    class BugTag(TaggedItemBase):\r\n    \r\n        content_object = models.ForeignKey('Bug')\r\n        note = models.CharField(max_length=50)\r\n    \r\n    \r\n    class Bug(models.Model):\r\n    \r\n        name = models.CharField(max_length=100)\r\n        tags = TaggableManager(through=BugTag)\r\n\r\nMake your initial migrations with `manage.py makemigrations <appname>` then run with `manage.py migrate`.\r\n\r\nThe `migrate` command will fail with an exception like:\r\n\r\n        Operations to perform:\r\n      Apply all migrations: sessions, admin, auth, contenttypes, taggit, bug\r\n    Running migrations:\r\n      Applying bug.0001_initial...Traceback (most recent call last):\r\n      File \"./manage.py\", line 7, in <module>\r\n        execute_from_command_line(sys.argv)\r\n      File \"/home/username/.virtualenvs/sqlitebug/local/lib/python2.7/site-packages/django/core/management/__init__.py\", line 385, in execute_from_command_line\r\n        utility.execute()\r\n      File \"/home/username/.virtualenvs/sqlitebug/local/lib/python2.7/site-packages/django/core/management/__init__.py\", line 377, in execute\r\n        self.fetch_command(subcommand).run_from_argv(self.argv)\r\n      File \"/home/username/.virtualenvs/sqlitebug/local/lib/python2.7/site-packages/django/core/management/base.py\", line 288, in run_from_argv\r\n        self.execute(*args, **options.__dict__)\r\n      File \"/home/username/.virtualenvs/sqlitebug/local/lib/python2.7/site-packages/django/core/management/base.py\", line 338, in execute\r\n        output = self.handle(*args, **options)\r\n      File \"/home/username/.virtualenvs/sqlitebug/local/lib/python2.7/site-packages/django/core/management/commands/migrate.py\", line 161, in handle\r\n        executor.migrate(targets, plan, fake=options.get(\"fake\", False))\r\n      File \"/home/username/.virtualenvs/sqlitebug/local/lib/python2.7/site-packages/django/db/migrations/executor.py\", line 68, in migrate\r\n        self.apply_migration(migration, fake=fake)\r\n      File \"/home/username/.virtualenvs/sqlitebug/local/lib/python2.7/site-packages/django/db/migrations/executor.py\", line 102, in apply_migration\r\n        migration.apply(project_state, schema_editor)\r\n      File \"/home/username/.virtualenvs/sqlitebug/local/lib/python2.7/site-packages/django/db/migrations/migration.py\", line 108, in apply\r\n        operation.database_forwards(self.app_label, schema_editor, project_state, new_state)\r\n      File \"/home/username/.virtualenvs/sqlitebug/local/lib/python2.7/site-packages/django/db/migrations/operations/fields.py\", line 37, in database_forwards\r\n        field,\r\n      File \"/home/username/.virtualenvs/sqlitebug/local/lib/python2.7/site-packages/django/db/backends/sqlite3/schema.py\", line 177, in add_field\r\n        self._remake_table(model, create_fields=[field])\r\n      File \"/home/username/.virtualenvs/sqlitebug/local/lib/python2.7/site-packages/django/db/backends/sqlite3/schema.py\", line 145, in _remake_table\r\n        self.quote_name(model._meta.db_table),\r\n      File \"/home/username/.virtualenvs/sqlitebug/local/lib/python2.7/site-packages/django/db/backends/schema.py\", line 103, in execute\r\n        cursor.execute(sql, params)\r\n      File \"/home/username/.virtualenvs/sqlitebug/local/lib/python2.7/site-packages/django/db/backends/utils.py\", line 81, in execute\r\n        return super(CursorDebugWrapper, self).execute(sql, params)\r\n      File \"/home/username/.virtualenvs/sqlitebug/local/lib/python2.7/site-packages/django/db/backends/utils.py\", line 65, in execute\r\n        return self.cursor.execute(sql, params)\r\n      File \"/home/username/.virtualenvs/sqlitebug/local/lib/python2.7/site-packages/django/db/utils.py\", line 94, in __exit__\r\n        six.reraise(dj_exc_type, dj_exc_value, traceback)\r\n      File \"/home/username/.virtualenvs/sqlitebug/local/lib/python2.7/site-packages/django/db/backends/utils.py\", line 65, in execute\r\n        return self.cursor.execute(sql, params)\r\n      File \"/home/username/.virtualenvs/sqlitebug/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py\", line 485, in execute\r\n        return Database.Cursor.execute(self, query, params)\r\n    django.db.utils.OperationalError: table bug_bug__new has no column named tags\r\n    \r\nThe SQL causing the issue is:\r\n\r\n    SELECT name FROM sqlite_master\r\n        WHERE type in ('table', 'view') AND NOT name='sqlite_sequence'\r\n        ORDER BY name\r\n    BEGIN\r\n    CREATE TABLE \"bug_bug\" (\"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT, \"name\" varchar(100) NOT NULL)\r\n    CREATE TABLE \"bug_bugtag\" (\"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT, \"note\" varchar(50) NOT NULL, \"content_object_id\" integer NOT NULL REFERENCES \"bug_bug\" (\"id\"), \"tag_id\" integer NOT NULL REFERENCES \"taggit_tag\" (\"id\"))\r\n    CREATE TABLE \"bug_bug__new\" (\"id\" integer NOT NULL PRIMARY KEY AUTOINCREMENT, \"name\" varchar(100) NOT NULL)\r\n    INSERT INTO \"bug_bug__new\" (\"tags\", \"id\", \"name\") SELECT NULL, \"id\", \"name\" FROM \"bug_bug\"\r\n\r\nDjango 1.7.1 doesn't exhibit the issue, and it's present in both the develop branch of taggit and the latest, 0.12.2, release."},"comment":{"url":"https://api.github.com/repos/alex/django-taggit/issues/comments/76474388","html_url":"https://github.com/alex/django-taggit/issues/285#issuecomment-76474388","issue_url":"https://api.github.com/repos/alex/django-taggit/issues/285","id":76474388,"user":{"login":"alex","id":772,"avatar_url":"https://avatars.githubusercontent.com/u/772?v=3","gravatar_id":"","url":"https://api.github.com/users/alex","html_url":"https://github.com/alex","followers_url":"https://api.github.com/users/alex/followers","following_url":"https://api.github.com/users/alex/following{/other_user}","gists_url":"https://api.github.com/users/alex/gists{/gist_id}","starred_url":"https://api.github.com/users/alex/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alex/subscriptions","organizations_url":"https://api.github.com/users/alex/orgs","repos_url":"https://api.github.com/users/alex/repos","events_url":"https://api.github.com/users/alex/events{/privacy}","received_events_url":"https://api.github.com/users/alex/received_events","type":"User","site_admin":false},"created_at":"2015-02-27T21:24:42Z","updated_at":"2015-02-27T21:24:42Z","body":"I'd like to find a way to have a maintainer under the current repo/pypi\nproject/etc.\n\nOn Fri, Feb 27, 2015 at 1:22 PM, Luke Pomfrey <notifications@github.com>\nwrote:\n\n> @frewsxcv <https://github.com/frewsxcv> I don't mind taking over\n> maintenance as long as no one else wants to or has any objections. But,\n> maybe commit access to this repository and the pypi project would be better\n> so it could stay in the same place and keep its name?\n>\n> —\n> Reply to this email directly or view it on GitHub\n> <https://github.com/alex/django-taggit/issues/285#issuecomment-76474093>.\n>\n\n\n\n-- \n\"I disapprove of what you say, but I will defend to the death your right to\nsay it.\" -- Evelyn Beatrice Hall (summarizing Voltaire)\n\"The people's good is the highest law.\" -- Cicero\nGPG Key fingerprint: 125F 5C67 DFE9 4084\n"}}