{"action":"created","issue":{"url":"https://api.github.com/repos/PokemonGoMap/PokemonGo-Map/issues/1106","repository_url":"https://api.github.com/repos/PokemonGoMap/PokemonGo-Map","labels_url":"https://api.github.com/repos/PokemonGoMap/PokemonGo-Map/issues/1106/labels{/name}","comments_url":"https://api.github.com/repos/PokemonGoMap/PokemonGo-Map/issues/1106/comments","events_url":"https://api.github.com/repos/PokemonGoMap/PokemonGo-Map/issues/1106/events","html_url":"https://github.com/PokemonGoMap/PokemonGo-Map/issues/1106","id":174822860,"number":1106,"title":"Create Tables paradox","user":{"login":"Xcelled","id":5599341,"avatar_url":"https://avatars.githubusercontent.com/u/5599341?v=3","gravatar_id":"","url":"https://api.github.com/users/Xcelled","html_url":"https://github.com/Xcelled","followers_url":"https://api.github.com/users/Xcelled/followers","following_url":"https://api.github.com/users/Xcelled/following{/other_user}","gists_url":"https://api.github.com/users/Xcelled/gists{/gist_id}","starred_url":"https://api.github.com/users/Xcelled/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Xcelled/subscriptions","organizations_url":"https://api.github.com/users/Xcelled/orgs","repos_url":"https://api.github.com/users/Xcelled/repos","events_url":"https://api.github.com/users/Xcelled/events{/privacy}","received_events_url":"https://api.github.com/users/Xcelled/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/PokemonGoMap/PokemonGo-Map/labels/bugfix","name":"bugfix","color":"ee0701"},{"url":"https://api.github.com/repos/PokemonGoMap/PokemonGo-Map/labels/Important","name":"Important","color":"ff0000"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-09-02T18:38:09Z","updated_at":"2016-09-05T00:57:28Z","closed_at":null,"body":"<!--\r\n  \r\n  FOR FEATURE REQUESTS GO TO:\r\n  \r\n  http://feathub.com/PokemonGoMap/PokemonGo-Map/\r\n  \r\n  ISSUES ARE NOT FOR SUPPORT!!!\r\n  ISSUES ARE NOT FOR SUPPORT!!!\r\n  ISSUES ARE NOT FOR SUPPORT!!!\r\n  ISSUES ARE NOT FOR SUPPORT!!!\r\n  ISSUES ARE NOT FOR SUPPORT!!!\r\n  ISSUES ARE NOT FOR SUPPORT!!!\r\n  ISSUES ARE NOT FOR SUPPORT!!!\r\n  ISSUES ARE NOT FOR SUPPORT!!!\r\n\r\n  Join discord (channel: #help) for support at this link: https://discord.gg/PWp2bAm\r\n\r\n-->\r\n\r\n<!--- Provide a general summary of the issue in the Title above -->\r\n\r\n## Expected Behavior\r\nMigration should happen automatically\r\n\r\n## Current Behavior\r\nWhen migrating, the program checks the DB schema version and upgrades it first. If the migration relies on a new table, that table is not created before the migration runs, resulting in a missing table error.\r\n\r\n## Possible Solution\r\nReorder table creation to appear before the schema upgrade, or possibly integrate table creation into the migration code.\r\n\r\n## Steps to Reproduce (for bugs)\r\n<!--- Provide a link to a live example, or an unambiguous set of steps to -->\r\n<!--- reproduce this bug. Include code to reproduce, if relevant -->\r\n1. Run a pogom on db schema version 5\r\n2. Update the code to version 7\r\n3. Run the program\r\n\r\n## Context\r\nCouldn't run the program without manually reordering the create calls.\r\n\r\n```\r\n2016-09-02 18:08:58,022 [      MainThread][     runserver][    INFO] Parsed location is: 43.0833/-77.6784/163.4727 (lat/lng/alt)\r\n2016-09-02 18:08:58,081 [      MainThread][        models][    INFO] Connecting\r\nto MySQL database on localhost:3306\r\n2016-09-02 18:08:58,179 [      MainThread][        models][    INFO] Detected database version 5, updating to 7\r\nTraceback (most recent call last):\r\n  File \"runserver.py\", line 250, in <module>\r\n    main()\r\n  File \"runserver.py\", line 160, in main\r\n    create_tables(db)\r\n  File \"/home/scott/PokemonGo-Map/pogom/models.py\", line 851, in create_tables\r\n    verify_database_schema(db)\r\n  File \"/home/scott/PokemonGo-Map/pogom/models.py\", line 879, in verify_database_schema\r\n    database_migrate(db, db_ver)\r\n  File \"/home/scott/PokemonGo-Map/pogom/models.py\", line 935, in database_migrate\r\n    migrator.add_column('gymdetails', 'description', TextField(null=True, default=\"\"))\r\n  File \"/usr/local/lib/python2.7/dist-packages/playhouse/migrate.py\", line 684,\r\nin migrate\r\n    operation.run()\r\n  File \"/usr/local/lib/python2.7/dist-packages/playhouse/migrate.py\", line 144,\r\nin run\r\n    getattr(self.migrator, self.method)(*self.args, **kwargs))\r\n  File \"/usr/local/lib/python2.7/dist-packages/playhouse/migrate.py\", line 133,\r\nin _handle_result\r\n    self.execute(result)\r\n  File \"/usr/local/lib/python2.7/dist-packages/playhouse/migrate.py\", line 129,\r\nin execute\r\n    self.migrator.database.execute_sql(sql, params)\r\n  File \"/usr/local/lib/python2.7/dist-packages/playhouse/shortcuts.py\", line 203, in execute_sql\r\n    sql, params, require_commit)\r\n  File \"/usr/local/lib/python2.7/dist-packages/peewee.py\", line 3492, in execute_sql\r\n    self.commit()\r\n  File \"/usr/local/lib/python2.7/dist-packages/peewee.py\", line 3316, in __exit__\r\n    reraise(new_type, new_type(*exc_args), traceback)\r\n  File \"/usr/local/lib/python2.7/dist-packages/peewee.py\", line 3485, in execute_sql\r\n    cursor.execute(sql, params or ())\r\n  File \"/usr/local/lib/python2.7/dist-packages/pymysql/cursors.py\", line 161, in execute\r\n    result = self._query(query)\r\n  File \"/usr/local/lib/python2.7/dist-packages/pymysql/cursors.py\", line 317, in _query\r\n    conn.query(q)\r\n  File \"/usr/local/lib/python2.7/dist-packages/pymysql/connections.py\", line 837, in query\r\n    self._affected_rows = self._read_query_result(unbuffered=unbuffered)\r\n  File \"/usr/local/lib/python2.7/dist-packages/pymysql/connections.py\", line 1021, in _read_query_result\r\n    result.read()\r\n  File \"/usr/local/lib/python2.7/dist-packages/pymysql/connections.py\", line 1304, in read\r\n    first_packet = self.connection._read_packet()\r\n  File \"/usr/local/lib/python2.7/dist-packages/pymysql/connections.py\", line 983, in _read_packet\r\n    packet.check_error()\r\n  File \"/usr/local/lib/python2.7/dist-packages/pymysql/connections.py\", line 395, in check_error\r\n    err.raise_mysql_exception(self._data)\r\n  File \"/usr/local/lib/python2.7/dist-packages/pymysql/err.py\", line 120, in raise_mysql_exception\r\n    _check_mysql_exception(errinfo)\r\n  File \"/usr/local/lib/python2.7/dist-packages/pymysql/err.py\", line 112, in _check_mysql_exception\r\n    raise errorclass(errno, errorvalue)\r\npeewee.ProgrammingError: (1146, u\"Table 'pogom.gymdetails' doesn't exist\")\r\n```\r\n\r\n## Your Environment\r\n<!--- Include as many relevant details about the environment you experienced the bug in -->\r\n* Version used: develop\r\n* Environment name and version (e.g. Python 2.7):  2.7.9\r\n* Operating System and version (desktop or mobile): Raspbian\r\n"},"comment":{"url":"https://api.github.com/repos/PokemonGoMap/PokemonGo-Map/issues/comments/244639020","html_url":"https://github.com/PokemonGoMap/PokemonGo-Map/issues/1106#issuecomment-244639020","issue_url":"https://api.github.com/repos/PokemonGoMap/PokemonGo-Map/issues/1106","id":244639020,"user":{"login":"Wolfsblvt","id":9962104,"avatar_url":"https://avatars.githubusercontent.com/u/9962104?v=3","gravatar_id":"","url":"https://api.github.com/users/Wolfsblvt","html_url":"https://github.com/Wolfsblvt","followers_url":"https://api.github.com/users/Wolfsblvt/followers","following_url":"https://api.github.com/users/Wolfsblvt/following{/other_user}","gists_url":"https://api.github.com/users/Wolfsblvt/gists{/gist_id}","starred_url":"https://api.github.com/users/Wolfsblvt/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Wolfsblvt/subscriptions","organizations_url":"https://api.github.com/users/Wolfsblvt/orgs","repos_url":"https://api.github.com/users/Wolfsblvt/repos","events_url":"https://api.github.com/users/Wolfsblvt/events{/privacy}","received_events_url":"https://api.github.com/users/Wolfsblvt/received_events","type":"User","site_admin":false},"created_at":"2016-09-05T00:57:28Z","updated_at":"2016-09-05T00:57:28Z","body":"Same error here.\r\nAlso note that if the migration throws an exception (like this one here) the execution breaks, but version number in DB is already set to 7. So the migration is not rolled back or anything, and I am quite sure it hasn't finished everything."}}
{"actor":{"display_login":"Wolfsblvt"}}