{"action":"opened","issue":{"url":"https://api.github.com/repos/hashicorp/terraform/issues/10740","repository_url":"https://api.github.com/repos/hashicorp/terraform","labels_url":"https://api.github.com/repos/hashicorp/terraform/issues/10740/labels{/name}","comments_url":"https://api.github.com/repos/hashicorp/terraform/issues/10740/comments","events_url":"https://api.github.com/repos/hashicorp/terraform/issues/10740/events","html_url":"https://github.com/hashicorp/terraform/issues/10740","id":195686253,"number":10740,"title":"Proposal: mysql_schema resource","user":{"login":"joshgarnett","id":391425,"avatar_url":"https://avatars.githubusercontent.com/u/391425?v=3","gravatar_id":"","url":"https://api.github.com/users/joshgarnett","html_url":"https://github.com/joshgarnett","followers_url":"https://api.github.com/users/joshgarnett/followers","following_url":"https://api.github.com/users/joshgarnett/following{/other_user}","gists_url":"https://api.github.com/users/joshgarnett/gists{/gist_id}","starred_url":"https://api.github.com/users/joshgarnett/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshgarnett/subscriptions","organizations_url":"https://api.github.com/users/joshgarnett/orgs","repos_url":"https://api.github.com/users/joshgarnett/repos","events_url":"https://api.github.com/users/joshgarnett/events{/privacy}","received_events_url":"https://api.github.com/users/joshgarnett/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-12-15T00:41:27Z","updated_at":"2016-12-15T00:41:27Z","closed_at":null,"body":"With Terraform being responsible for creating my instances, databases, and container services, the biggest gap right now is schema management.  You can use a local-exec provisioner on a mysql_database resource to apply a schema, but this is only executed when the database is first created and does not handle updates to the schema.\r\n\r\nTo address this my idea is to create a mysql_schema resource.  It would take two attributes, name and schemas.  Name would be the database name and could be a reference to mysql_database.  Schemas would be a list of schema definitions to apply.  \r\n\r\nSchemas would be applied in order.  The hash of each schema and the index of the last schema applied would be store in the terraform state file.  If the hash of any already applied schema changes, terraform would exit with an error.  If the list size changes, it will apply any of the new schemas that have been added to the list.  If applying any of the schemas fails, terraform will persist the index that was success, and then exit with an error.\r\n\r\nExample:\r\n\r\n```\r\nresource \"mysql_database\" \"app\" {\r\n  name = \"my_awesome_app\"\r\n}\r\n\r\nresource \"mysql_schema\" \"app\" {\r\n  name = \"${mysql_database.app.name}\"\r\n  schemas = [file(\"initial.sql\"), file(\"add_column.sql\"), file(\"add_index.sql\")]\r\n}\r\n```\r\n\r\nIf there are no objections or concerns with the design, I'm going to start working on a PR to add the functionality.\r\n"}}
{"actor":{"display_login":"joshgarnett"}}