{"action":"closed","issue":{"url":"https://api.github.com/repos/sunitparekh/data-anonymization/issues/14","labels_url":"https://api.github.com/repos/sunitparekh/data-anonymization/issues/14/labels{/name}","comments_url":"https://api.github.com/repos/sunitparekh/data-anonymization/issues/14/comments","events_url":"https://api.github.com/repos/sunitparekh/data-anonymization/issues/14/events","html_url":"https://github.com/sunitparekh/data-anonymization/issues/14","id":7357771,"number":14,"title":"Clear destination database before each run to prevent duplicate primary key errors? ","user":{"login":"justinwiley","id":4262,"avatar_url":"https://avatars.githubusercontent.com/u/4262?v=3","gravatar_id":"","url":"https://api.github.com/users/justinwiley","html_url":"https://github.com/justinwiley","followers_url":"https://api.github.com/users/justinwiley/followers","following_url":"https://api.github.com/users/justinwiley/following{/other_user}","gists_url":"https://api.github.com/users/justinwiley/gists{/gist_id}","starred_url":"https://api.github.com/users/justinwiley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/justinwiley/subscriptions","organizations_url":"https://api.github.com/users/justinwiley/orgs","repos_url":"https://api.github.com/users/justinwiley/repos","events_url":"https://api.github.com/users/justinwiley/events{/privacy}","received_events_url":"https://api.github.com/users/justinwiley/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/sunitparekh/data-anonymization/milestones/6","html_url":"https://github.com/sunitparekh/data-anonymization/milestones/0.7.0","labels_url":"https://api.github.com/repos/sunitparekh/data-anonymization/milestones/6/labels","id":625975,"number":6,"title":"0.7.0","description":null,"creator":{"login":"sunitparekh","id":177850,"avatar_url":"https://avatars.githubusercontent.com/u/177850?v=3","gravatar_id":"","url":"https://api.github.com/users/sunitparekh","html_url":"https://github.com/sunitparekh","followers_url":"https://api.github.com/users/sunitparekh/followers","following_url":"https://api.github.com/users/sunitparekh/following{/other_user}","gists_url":"https://api.github.com/users/sunitparekh/gists{/gist_id}","starred_url":"https://api.github.com/users/sunitparekh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sunitparekh/subscriptions","organizations_url":"https://api.github.com/users/sunitparekh/orgs","repos_url":"https://api.github.com/users/sunitparekh/repos","events_url":"https://api.github.com/users/sunitparekh/events{/privacy}","received_events_url":"https://api.github.com/users/sunitparekh/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":1,"state":"open","created_at":"2014-04-10T09:19:00Z","updated_at":"2015-03-09T17:13:49Z","due_on":null,"closed_at":null},"comments":1,"created_at":"2012-10-04T17:50:03Z","updated_at":"2015-03-09T17:13:49Z","closed_at":"2015-03-09T17:13:49Z","body":"I generated a new whitelist via the command line utility, created a new destination database 'snapshot', and executed using the following script:\r\n\r\n```ruby\r\nrequire File.expand_path(File.join(File.dirname(__FILE__), '..', 'config', 'environment'))\r\nrequire 'data-anonymization'\r\n\r\nDataAnon::Utils::Logging.logger.level = Logger::INFO\r\n\r\ndatabase 'Example' do\r\n  strategy DataAnon::Strategy::Whitelist\r\n  source_db ActiveRecord::Base.configurations['development']\r\n  destination_db ActiveRecord::Base.configurations['snapshot']\r\n  \r\n  table 'answers' do\r\n    primary_key 'id'\r\n    whitelist 'question_id'\r\n    whitelist 'name'\r\n    whitelist 'position'\r\n    whitelist 'value'\r\n    whitelist 'created_at'\r\n    whitelist 'updated_at'\r\n  end\r\nend\r\n```\r\n\r\nThis failed, since there were no tables in the source database.  I copied the table structure, and re-ran the script.\r\n\r\nThis succeeded the first time, but fails the second time, with duplicate ID errors:\r\n\r\n```\r\nMysql2::Error: Duplicate entry '3355' for key 'PRIMARY': INSERT INTO `answers` (`created_at`, `id`, `name`, `position`, `question_id`, `updated_at`, `value`) VALUES ('2012-10-04 17:35:03', 3355, NULL, NULL, NULL, '2012-10-04 17:35:03', NULL)\r\n```\r\nIs there some way to have clear the destination database before each run?"}}