{"action":"opened","issue":{"url":"https://api.github.com/repos/Connexions/cnx-deploy/issues/361","repository_url":"https://api.github.com/repos/Connexions/cnx-deploy","labels_url":"https://api.github.com/repos/Connexions/cnx-deploy/issues/361/labels{/name}","comments_url":"https://api.github.com/repos/Connexions/cnx-deploy/issues/361/comments","events_url":"https://api.github.com/repos/Connexions/cnx-deploy/issues/361/events","html_url":"https://github.com/Connexions/cnx-deploy/issues/361","id":250121247,"number":361,"title":"Unable to migrate database on staging","user":{"login":"karenc","id":153353,"avatar_url":"https://avatars3.githubusercontent.com/u/153353?v=4","gravatar_id":"","url":"https://api.github.com/users/karenc","html_url":"https://github.com/karenc","followers_url":"https://api.github.com/users/karenc/followers","following_url":"https://api.github.com/users/karenc/following{/other_user}","gists_url":"https://api.github.com/users/karenc/gists{/gist_id}","starred_url":"https://api.github.com/users/karenc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/karenc/subscriptions","organizations_url":"https://api.github.com/users/karenc/orgs","repos_url":"https://api.github.com/users/karenc/repos","events_url":"https://api.github.com/users/karenc/events{/privacy}","received_events_url":"https://api.github.com/users/karenc/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2017-08-14T18:56:04Z","updated_at":"2017-08-14T18:56:04Z","closed_at":null,"body":"## Summary\r\n\r\nWhen running main.yml on staging, the database migration handler failed:\r\n\r\n```\r\nRUNNING HANDLER [repository_db : migrate repository database] *********************************************************************************************************************************************************************************\r\nfatal: [staging08.cnx.org]: FAILED! => {\"changed\": true, \"cmd\": [\"/var/cnx/venvs/publishing/bin/dbmigrator\", \"--config\", \"/etc/cnx/archive/app.ini\", \"--context\", \"cnx-db\", \"migrate\"], \"delta\": \"0:00:02.394862\", \"end\": \"2017-08-14 16:10:37.530792\", \"failed\": true, \"rc\": 1, \"start\": \"2017-08-14 16:10:35.135930\", \"stderr\": \"Traceback (most recent call last):\\n  File \\\"/var/cnx/venvs/publishing/bin/dbmigrator\\\", line 11, in <module>\\n    sys.exit(main())\\n  File \\\"/var/cnx/venvs/publishing/local/lib/python2.7/site-packages/dbmigrator/cli.py\\\", line 89, in main\\n    return args['cmmd'](**args)\\n  File \\\"/var/cnx/venvs/publishing/local/lib/python2.7/site-packages/dbmigrator/utils.py\\\", line 83, in wrapper\\n    return func(cursor, *args, **kwargs)\\n  File \\\"/var/cnx/venvs/publishing/local/lib/python2.7/site-packages/dbmigrator/commands/migrate.py\\\", line 30, in cli_command\\n    migration)\\n  File \\\"/var/cnx/venvs/publishing/local/lib/python2.7/site-packages/dbmigrator/utils.py\\\", line 150, in compare_schema\\n    callback(*args, **kwargs)\\n  File \\\"/var/cnx/venvs/publishing/local/lib/python2.7/site-packages/dbmigrator/utils.py\\\", line 161, in run_migration\\n    migration.up(cursor)\\n  File \\\"../../var/cnx/venvs/publishing/local/lib/python2.7/site-packages/cnxdb/migrations/20160506121704_add_filename_to_resources.py\\\", line 7, in up\\n    ADD COLUMN filename TEXT\\\"\\\"\\\")\\npsycopg2.ProgrammingError: column \\\"filename\\\" of relation \\\"pending_resources\\\" already exists\", \"stderr_lines\": [\"Traceback (most recent call last):\", \"  File \\\"/var/cnx/venvs/publishing/bin/dbmigrator\\\", line 11, in <module>\", \"    sys.exit(main())\", \"  File \\\"/var/cnx/venvs/publishing/local/lib/python2.7/site-packages/dbmigrator/cli.py\\\", line 89, in main\", \"    return args['cmmd'](**args)\", \"  File \\\"/var/cnx/venvs/publishing/local/lib/python2.7/site-packages/dbmigrator/utils.py\\\", line 83, in wrapper\", \"    return func(cursor, *args, **kwargs)\", \"  File \\\"/var/cnx/venvs/publishing/local/lib/python2.7/site-packages/dbmigrator/commands/migrate.py\\\", line 30, in cli_command\", \"    migration)\", \"  File \\\"/var/cnx/venvs/publishing/local/lib/python2.7/site-packages/dbmigrator/utils.py\\\", line 150, in compare_schema\", \"    callback(*args, **kwargs)\", \"  File \\\"/var/cnx/venvs/publishing/local/lib/python2.7/site-packages/dbmigrator/utils.py\\\", line 161, in run_migration\", \"    migration.up(cursor)\", \"  File \\\"../../var/cnx/venvs/publishing/local/lib/python2.7/site-packages/cnxdb/migrations/20160506121704_add_filename_to_resources.py\\\", line 7, in up\", \"    ADD COLUMN filename TEXT\\\"\\\"\\\")\", \"psycopg2.ProgrammingError: column \\\"filename\\\" of relation \\\"pending_resources\\\" already exists\"], \"stdout\": \"Running migration 20160506121704 add_filename_to_resources\", \"stdout_lines\": [\"Running migration 20160506121704 add_filename_to_resources\"]}\r\n```\r\n\r\nTo make it easier to read, the traceback:\r\n\r\n```\r\nRUNNING HANDLER [repository_db : migrate repository database] *********************************************************************************************************************************************************************************\r\n\"cmd\": [\"/var/cnx/venvs/publishing/bin/dbmigrator\", \"--config\", \"/etc/cnx/archive/app.ini\", \"--context\", \"cnx-db\", \"migrate\"],\r\n\"stderr\": \"Traceback (most recent call last):\r\n  File \\\"/var/cnx/venvs/publishing/bin/dbmigrator\\\", line 11, in <module>\r\n    sys.exit(main())\r\n  File \\\"/var/cnx/venvs/publishing/local/lib/python2.7/site-packages/dbmigrator/cli.py\\\", line 89, in main\r\n    return args['cmmd'](**args)\r\n  File \\\"/var/cnx/venvs/publishing/local/lib/python2.7/site-packages/dbmigrator/utils.py\\\", line 83, in wrapper\r\n    return func(cursor, *args, **kwargs)\r\n  File \\\"/var/cnx/venvs/publishing/local/lib/python2.7/site-packages/dbmigrator/commands/migrate.py\\\", line 30, in cli_command\r\n    migration)\r\n  File \\\"/var/cnx/venvs/publishing/local/lib/python2.7/site-packages/dbmigrator/utils.py\\\", line 150, in compare_schema\r\n    callback(*args, **kwargs)\r\n  File \\\"/var/cnx/venvs/publishing/local/lib/python2.7/site-packages/dbmigrator/utils.py\\\", line 161, in run_migration\r\n    migration.up(cursor)\r\n  File \\\"../../var/cnx/venvs/publishing/local/lib/python2.7/site-packages/cnxdb/migrations/20160506121704_add_filename_to_resources.py\\\", line 7, in up\r\n    ADD COLUMN filename TEXT\\\"\\\"\\\")\r\npsycopg2.ProgrammingError: column \\\"filename\\\" of relation \\\"pending_resources\\\" already exists\",\r\n\"stdout\": \"Running migration 20160506121704 add_filename_to_resources\"\r\n```\r\n\r\nThere are 2 problems:\r\n\r\n1. The migration has already been applied to the database, but dbmigrator does not know about it.\r\n2. `cnx-db` migrations should not run because archive and publishing are running code that predates `cnx-db`.\r\n\r\n## Environment\r\n\r\nstaging (and probably prod)"}}
{"actor":{"display_login":"karenc"}}