{"action":"created","issue":{"url":"https://api.github.com/repos/rubenv/sql-migrate/issues/20","labels_url":"https://api.github.com/repos/rubenv/sql-migrate/issues/20/labels{/name}","comments_url":"https://api.github.com/repos/rubenv/sql-migrate/issues/20/comments","events_url":"https://api.github.com/repos/rubenv/sql-migrate/issues/20/events","html_url":"https://github.com/rubenv/sql-migrate/issues/20","id":98160626,"number":20,"title":"Note 1050: Table 'gorp_migrations' already exists","user":{"login":"JalfResi","id":589853,"avatar_url":"https://avatars.githubusercontent.com/u/589853?v=3","gravatar_id":"","url":"https://api.github.com/users/JalfResi","html_url":"https://github.com/JalfResi","followers_url":"https://api.github.com/users/JalfResi/followers","following_url":"https://api.github.com/users/JalfResi/following{/other_user}","gists_url":"https://api.github.com/users/JalfResi/gists{/gist_id}","starred_url":"https://api.github.com/users/JalfResi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JalfResi/subscriptions","organizations_url":"https://api.github.com/users/JalfResi/orgs","repos_url":"https://api.github.com/users/JalfResi/repos","events_url":"https://api.github.com/users/JalfResi/events{/privacy}","received_events_url":"https://api.github.com/users/JalfResi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-07-30T12:46:21Z","updated_at":"2015-08-07T16:31:46Z","closed_at":null,"body":"I have a program that attempts to apply any migrations it has not applied run after connecting to the database. However, when I run my program I get:\r\n\r\n```bash\r\nNote 1050: Table 'gorp_migrations' already exists\r\n```\r\n\r\nThe migrations are stored using bindata. Here is the function definition:\r\n\r\n```golang\r\n// Open returns a DB reference for a data source.\r\nfunc Open(dataSourceName string) (*DB, error) {\r\n\tdb, err := sql.Open(\"mysql\", dataSourceName)\r\n\r\n\tif err != nil {\r\n\t\treturn nil, err\r\n\t}\r\n\r\n\tdb.Ping()\r\n\tif err != nil {\r\n\t\treturn nil, err\r\n\t}\r\n\r\n\tmigrations := &migrate.AssetMigrationSource{\r\n\t\tAsset:    Asset,\r\n\t\tAssetDir: AssetDir,\r\n\t\tDir:      \"migrations\",\r\n\t}\r\n\r\n\tn, err := migrate.Exec(db, \"mysql\", migrations, migrate.Up)\r\n\tif err != nil {\r\n\t\treturn nil, err\r\n\t}\r\n\tfmt.Printf(\"Applied %d migrations!\\n\", n)\r\n\r\n\treturn &DB{db}, nil\r\n}\r\n```\r\n\r\nAny pointers on what I'm doing wrong? It looks like the call to CreateTablesIfNotExists() isn't working correctly; it appears to be returning an error and returning."},"comment":{"url":"https://api.github.com/repos/rubenv/sql-migrate/issues/comments/128757642","html_url":"https://github.com/rubenv/sql-migrate/issues/20#issuecomment-128757642","issue_url":"https://api.github.com/repos/rubenv/sql-migrate/issues/20","id":128757642,"user":{"login":"JalfResi","id":589853,"avatar_url":"https://avatars.githubusercontent.com/u/589853?v=3","gravatar_id":"","url":"https://api.github.com/users/JalfResi","html_url":"https://github.com/JalfResi","followers_url":"https://api.github.com/users/JalfResi/followers","following_url":"https://api.github.com/users/JalfResi/following{/other_user}","gists_url":"https://api.github.com/users/JalfResi/gists{/gist_id}","starred_url":"https://api.github.com/users/JalfResi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JalfResi/subscriptions","organizations_url":"https://api.github.com/users/JalfResi/orgs","repos_url":"https://api.github.com/users/JalfResi/repos","events_url":"https://api.github.com/users/JalfResi/events{/privacy}","received_events_url":"https://api.github.com/users/JalfResi/received_events","type":"User","site_admin":false},"created_at":"2015-08-07T16:31:46Z","updated_at":"2015-08-07T16:31:46Z","body":"IS there anymore information you need from me to help diagnose this issue? The Open function gets called by main() once on app start. If clear the schema, run the app, the migrations all go in correctly. If I add a new migration or run the app a second time with an existing up to date schema, the above error message occurs. Should I be check to see if the migration table is up to date somehow before attempting to run any migrations?"}}