dump_truck 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +94 -0
- data/Rakefile +6 -0
- data/dump_truck.gemspec +27 -0
- data/lib/dump_truck.rb +64 -0
- data/lib/dump_truck/configuration.rb +35 -0
- data/lib/dump_truck/database_configuration.rb +61 -0
- data/lib/dump_truck/loggable_truck.rb +41 -0
- data/lib/dump_truck/mysql.rb +7 -0
- data/lib/dump_truck/mysql/client.rb +73 -0
- data/lib/dump_truck/mysql/translator.rb +123 -0
- data/lib/dump_truck/schema_configuration.rb +55 -0
- data/lib/dump_truck/table_configuration.rb +63 -0
- data/lib/dump_truck/target.rb +13 -0
- data/lib/dump_truck/truck.rb +70 -0
- data/lib/dump_truck/version.rb +3 -0
- data/spec/configuration_spec.rb +22 -0
- data/spec/databases_configuration_spec.rb +29 -0
- data/spec/dump_truck_spec.rb +39 -0
- data/spec/fixtures/mysql/expected_dump.sql +147 -0
- data/spec/fixtures/mysql/permissions.sql +38 -0
- data/spec/fixtures/mysql/roles.sql +39 -0
- data/spec/fixtures/mysql/tables.sql +111 -0
- data/spec/fixtures/mysql/users.sql +71 -0
- data/spec/mysql/translator_spec.rb +115 -0
- data/spec/schema_configuration_spec.rb +44 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/table_configuration_spec.rb +124 -0
- data/spec/truck_spec.rb +51 -0
- metadata +179 -0
@@ -0,0 +1,38 @@
|
|
1
|
+
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
2
|
+
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
3
|
+
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
4
|
+
/*!40101 SET NAMES utf8 */;
|
5
|
+
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
6
|
+
/*!40103 SET TIME_ZONE='+00:00' */;
|
7
|
+
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
8
|
+
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
9
|
+
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
10
|
+
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
11
|
+
DROP TABLE IF EXISTS `permissions`;
|
12
|
+
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
13
|
+
/*!40101 SET character_set_client = utf8 */;
|
14
|
+
CREATE TABLE `permissions` (
|
15
|
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
16
|
+
`name` varchar(255) NOT NULL,
|
17
|
+
`created_at` datetime DEFAULT NULL,
|
18
|
+
`updated_at` datetime DEFAULT NULL,
|
19
|
+
PRIMARY KEY (`id`),
|
20
|
+
UNIQUE KEY `index_permissions_on_name` (`name`)
|
21
|
+
) ENGINE=InnoDB AUTO_INCREMENT=343 DEFAULT CHARSET=utf8;
|
22
|
+
/*!40101 SET character_set_client = @saved_cs_client */;
|
23
|
+
|
24
|
+
LOCK TABLES `permissions` WRITE;
|
25
|
+
/*!40000 ALTER TABLE `permissions` DISABLE KEYS */;
|
26
|
+
INSERT INTO `permissions` (`id`, `name`, `created_at`, `updated_at`) VALUES (11,'account:login','2009-08-11 11:10:17','2009-08-11 11:10:17'),(23,'job_artifacts:view','2009-08-11 11:10:17','2009-08-11 11:10:17'),(35,'charities:view','2009-08-11 11:10:17','2009-08-11 11:10:17'),(47,'charities:create','2009-08-11 11:10:17','2009-08-11 11:10:17'),(5,'charities:edit','2009-08-11 11:10:17','2009-08-11 11:10:17'),(60,'careers:create','2009-08-11 11:10:17','2009-08-11 11:10:17'),(67,'careers:view','2009-08-11 11:10:18','2009-08-11 11:10:18'),(89,'careers:edit','2009-08-11 11:10:18','2009-08-11 11:10:18'),(9,'media_stories:create','2009-08-11 11:10:18','2009-08-11 11:10:18'),(100,'media_stories:view','2009-08-11 11:10:18','2009-08-11 11:10:18'),(112,'media_stories:edit','2009-08-11 11:10:18','2009-08-11 11:10:18'),(122,'media_stories:destroy','2009-08-11 11:10:18','2009-08-11 11:10:18');
|
27
|
+
/*!40000 ALTER TABLE `permissions` ENABLE KEYS */;
|
28
|
+
UNLOCK TABLES;
|
29
|
+
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
30
|
+
|
31
|
+
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
32
|
+
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
33
|
+
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
34
|
+
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
35
|
+
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
36
|
+
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
37
|
+
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
38
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
2
|
+
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
3
|
+
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
4
|
+
/*!40101 SET NAMES utf8 */;
|
5
|
+
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
6
|
+
/*!40103 SET TIME_ZONE='+00:00' */;
|
7
|
+
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
8
|
+
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
9
|
+
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
10
|
+
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
11
|
+
DROP TABLE IF EXISTS `roles`;
|
12
|
+
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
13
|
+
/*!40101 SET character_set_client = utf8 */;
|
14
|
+
CREATE TABLE `roles` (
|
15
|
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
16
|
+
`name` varchar(255) NOT NULL,
|
17
|
+
`description` varchar(255) DEFAULT NULL,
|
18
|
+
`created_at` datetime DEFAULT NULL,
|
19
|
+
`updated_at` datetime DEFAULT NULL,
|
20
|
+
PRIMARY KEY (`id`),
|
21
|
+
UNIQUE KEY `index_roles_on_name` (`name`)
|
22
|
+
) ENGINE=InnoDB AUTO_INCREMENT=94 DEFAULT CHARSET=utf8;
|
23
|
+
/*!40101 SET character_set_client = @saved_cs_client */;
|
24
|
+
|
25
|
+
LOCK TABLES `roles` WRITE;
|
26
|
+
/*!40000 ALTER TABLE `roles` DISABLE KEYS */;
|
27
|
+
INSERT INTO `roles` (`id`, `name`, `description`, `created_at`, `updated_at`) VALUES (21,'Employee',NULL,'2009-08-11 11:10:17','2009-08-11 11:10:17'),(23,'Charity Management',NULL,'2009-08-11 11:10:17','2009-08-11 11:10:17'),(34,'Content Management',NULL,'2009-08-11 11:10:17','2009-08-11 11:10:17'),(84,'Email Management',NULL,'2009-08-11 11:10:18','2009-08-11 11:10:18'),(85,'Search Management',NULL,'2009-08-11 11:10:18','2009-08-11 11:10:18'),(96,'Net Promoter Management',NULL,'2009-08-11 11:10:18','2009-08-11 11:10:18'),(207,'Promo Management',NULL,'2009-08-11 11:10:18','2009-08-11 11:10:18'),(308,'Marketing Management',NULL,'2009-08-11 11:10:18','2009-08-11 11:10:18');
|
28
|
+
/*!40000 ALTER TABLE `roles` ENABLE KEYS */;
|
29
|
+
UNLOCK TABLES;
|
30
|
+
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
31
|
+
|
32
|
+
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
33
|
+
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
34
|
+
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
35
|
+
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
36
|
+
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
37
|
+
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
38
|
+
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
39
|
+
|
@@ -0,0 +1,111 @@
|
|
1
|
+
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
2
|
+
/*!40103 SET TIME_ZONE='+00:00' */;
|
3
|
+
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
4
|
+
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
5
|
+
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
6
|
+
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
7
|
+
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
8
|
+
/*!40101 SET character_set_client = utf8 */;
|
9
|
+
CREATE TABLE `permissions` (
|
10
|
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
11
|
+
`name` varchar(255) NOT NULL,
|
12
|
+
`created_at` datetime DEFAULT NULL,
|
13
|
+
`updated_at` datetime DEFAULT NULL,
|
14
|
+
PRIMARY KEY (`id`),
|
15
|
+
UNIQUE KEY `index_permissions_on_name` (`name`)
|
16
|
+
) ENGINE=InnoDB AUTO_INCREMENT=343 DEFAULT CHARSET=utf8;
|
17
|
+
/*!40101 SET character_set_client = @saved_cs_client */;
|
18
|
+
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
19
|
+
/*!40101 SET character_set_client = utf8 */;
|
20
|
+
CREATE TABLE `roles` (
|
21
|
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
22
|
+
`name` varchar(255) NOT NULL,
|
23
|
+
`description` varchar(255) DEFAULT NULL,
|
24
|
+
`created_at` datetime DEFAULT NULL,
|
25
|
+
`updated_at` datetime DEFAULT NULL,
|
26
|
+
PRIMARY KEY (`id`),
|
27
|
+
UNIQUE KEY `index_roles_on_name` (`name`)
|
28
|
+
) ENGINE=InnoDB AUTO_INCREMENT=94 DEFAULT CHARSET=utf8;
|
29
|
+
/*!40101 SET character_set_client = @saved_cs_client */;
|
30
|
+
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
31
|
+
/*!40101 SET character_set_client = utf8 */;
|
32
|
+
CREATE TABLE `users` (
|
33
|
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
34
|
+
`login` varchar(255) CHARACTER SET utf8 NOT NULL,
|
35
|
+
`email` varchar(255) CHARACTER SET utf8 NOT NULL,
|
36
|
+
`encrypted_password` varchar(128) NOT NULL DEFAULT '',
|
37
|
+
`password_salt` varchar(128) NOT NULL DEFAULT '',
|
38
|
+
`created_at` datetime DEFAULT NULL,
|
39
|
+
`updated_at` datetime DEFAULT NULL,
|
40
|
+
`remember_token` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
|
41
|
+
`remember_token_expires_at` datetime DEFAULT NULL,
|
42
|
+
`confirmed_agreement` tinyint(1) NOT NULL DEFAULT '0',
|
43
|
+
`first_name` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
|
44
|
+
`middle_name` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
|
45
|
+
`last_name` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
|
46
|
+
`role` int(11) DEFAULT '0',
|
47
|
+
`status` int(11) DEFAULT '0',
|
48
|
+
`pw_reset_code` varchar(40) CHARACTER SET utf8 DEFAULT NULL,
|
49
|
+
`activated` tinyint(1) DEFAULT '0',
|
50
|
+
`activation_key` varchar(40) DEFAULT NULL,
|
51
|
+
`telephone` varchar(255) DEFAULT NULL,
|
52
|
+
`confirmed_referral_terms` tinyint(1) DEFAULT '0',
|
53
|
+
`confirmed_referral_terms_at` datetime DEFAULT NULL,
|
54
|
+
`current_facility_id` int(11) DEFAULT NULL,
|
55
|
+
`selected_drive_id` int(11) DEFAULT NULL,
|
56
|
+
`triggers_qc` tinyint(1) NOT NULL DEFAULT '0',
|
57
|
+
`persistence_token` varchar(255) DEFAULT NULL,
|
58
|
+
`single_access_token` varchar(255) DEFAULT NULL,
|
59
|
+
`requires_ldap_authentication` tinyint(1) DEFAULT '0',
|
60
|
+
`sign_in_count` int(11) DEFAULT '0',
|
61
|
+
`current_sign_in_at` datetime DEFAULT NULL,
|
62
|
+
`last_sign_in_at` datetime DEFAULT NULL,
|
63
|
+
`current_sign_in_ip` varchar(255) DEFAULT NULL,
|
64
|
+
`last_sign_in_ip` varchar(255) DEFAULT NULL,
|
65
|
+
PRIMARY KEY (`id`),
|
66
|
+
UNIQUE KEY `index_users_on_email` (`email`),
|
67
|
+
UNIQUE KEY `index_users_on_single_access_token` (`single_access_token`),
|
68
|
+
UNIQUE KEY `index_users_on_pw_reset_code` (`pw_reset_code`),
|
69
|
+
KEY `index_users_on_activation_key` (`activation_key`),
|
70
|
+
KEY `index_users_on_activated` (`activated`),
|
71
|
+
KEY `index_users_on_last_name` (`last_name`)
|
72
|
+
) ENGINE=InnoDB AUTO_INCREMENT=919492 DEFAULT CHARSET=latin1;
|
73
|
+
/*!40101 SET character_set_client = @saved_cs_client */;
|
74
|
+
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
75
|
+
/*!40101 SET character_set_client = utf8 */;
|
76
|
+
CREATE TABLE `mail_queue` (
|
77
|
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
78
|
+
`subject` varchar(255) DEFAULT NULL,
|
79
|
+
`from` varchar(255) DEFAULT NULL,
|
80
|
+
`to` varchar(255) DEFAULT NULL,
|
81
|
+
`cc` varchar(255) DEFAULT NULL,
|
82
|
+
`bcc` varchar(255) DEFAULT NULL,
|
83
|
+
`charset` varchar(255) DEFAULT NULL,
|
84
|
+
`content_type` varchar(255) DEFAULT NULL,
|
85
|
+
`body` text,
|
86
|
+
`data` text,
|
87
|
+
`locked` tinyint(1) NOT NULL DEFAULT '0',
|
88
|
+
`priority` int(11) NOT NULL DEFAULT '3',
|
89
|
+
`tries` int(11) NOT NULL DEFAULT '0',
|
90
|
+
`maximum_tries` int(11) NOT NULL DEFAULT '3',
|
91
|
+
`created_at` datetime DEFAULT NULL,
|
92
|
+
`updated_at` datetime DEFAULT NULL,
|
93
|
+
`sent_at` datetime DEFAULT NULL,
|
94
|
+
`attachments` tinyint(1) DEFAULT '0',
|
95
|
+
PRIMARY KEY (`id`),
|
96
|
+
KEY `index_mail_queue_on_locked` (`locked`),
|
97
|
+
KEY `index_mail_queue_on_priority` (`priority`),
|
98
|
+
KEY `index_mail_queue_on_tries` (`tries`),
|
99
|
+
KEY `index_mail_queue_on_created_at` (`created_at`),
|
100
|
+
KEY `index_mail_queue_on_sent_at` (`sent_at`),
|
101
|
+
KEY `index_mail_queue_on_to` (`to`),
|
102
|
+
KEY `mail_queue_locked_sent_at_updated_at_tries` (`locked`,`sent_at`,`updated_at`,`tries`)
|
103
|
+
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1;
|
104
|
+
/*!40101 SET character_set_client = @saved_cs_client */;
|
105
|
+
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
106
|
+
|
107
|
+
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
108
|
+
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
109
|
+
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
110
|
+
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
111
|
+
|
@@ -0,0 +1,71 @@
|
|
1
|
+
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
|
2
|
+
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
|
3
|
+
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
|
4
|
+
/*!40101 SET NAMES utf8 */;
|
5
|
+
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
|
6
|
+
/*!40103 SET TIME_ZONE='+00:00' */;
|
7
|
+
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
|
8
|
+
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
|
9
|
+
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
|
10
|
+
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
|
11
|
+
DROP TABLE IF EXISTS `users`;
|
12
|
+
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
13
|
+
/*!40101 SET character_set_client = utf8 */;
|
14
|
+
CREATE TABLE `users` (
|
15
|
+
`id` int(11) NOT NULL AUTO_INCREMENT,
|
16
|
+
`login` varchar(255) CHARACTER SET utf8 NOT NULL,
|
17
|
+
`email` varchar(255) CHARACTER SET utf8 NOT NULL,
|
18
|
+
`encrypted_password` varchar(128) NOT NULL DEFAULT '',
|
19
|
+
`password_salt` varchar(128) NOT NULL DEFAULT '',
|
20
|
+
`created_at` datetime DEFAULT NULL,
|
21
|
+
`updated_at` datetime DEFAULT NULL,
|
22
|
+
`remember_token` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
|
23
|
+
`remember_token_expires_at` datetime DEFAULT NULL,
|
24
|
+
`confirmed_agreement` tinyint(1) NOT NULL DEFAULT '0',
|
25
|
+
`first_name` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
|
26
|
+
`middle_name` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
|
27
|
+
`last_name` varchar(255) CHARACTER SET utf8 DEFAULT NULL,
|
28
|
+
`role` int(11) DEFAULT '0',
|
29
|
+
`status` int(11) DEFAULT '0',
|
30
|
+
`pw_reset_code` varchar(40) CHARACTER SET utf8 DEFAULT NULL,
|
31
|
+
`activated` tinyint(1) DEFAULT '0',
|
32
|
+
`activation_key` varchar(40) DEFAULT NULL,
|
33
|
+
`telephone` varchar(255) DEFAULT NULL,
|
34
|
+
`confirmed_referral_terms` tinyint(1) DEFAULT '0',
|
35
|
+
`confirmed_referral_terms_at` datetime DEFAULT NULL,
|
36
|
+
`current_facility_id` int(11) DEFAULT NULL,
|
37
|
+
`selected_drive_id` int(11) DEFAULT NULL,
|
38
|
+
`triggers_qc` tinyint(1) NOT NULL DEFAULT '0',
|
39
|
+
`persistence_token` varchar(255) DEFAULT NULL,
|
40
|
+
`single_access_token` varchar(255) DEFAULT NULL,
|
41
|
+
`requires_ldap_authentication` tinyint(1) DEFAULT '0',
|
42
|
+
`sign_in_count` int(11) DEFAULT '0',
|
43
|
+
`current_sign_in_at` datetime DEFAULT NULL,
|
44
|
+
`last_sign_in_at` datetime DEFAULT NULL,
|
45
|
+
`current_sign_in_ip` varchar(255) DEFAULT NULL,
|
46
|
+
`last_sign_in_ip` varchar(255) DEFAULT NULL,
|
47
|
+
PRIMARY KEY (`id`),
|
48
|
+
UNIQUE KEY `index_users_on_email` (`email`),
|
49
|
+
UNIQUE KEY `index_users_on_single_access_token` (`single_access_token`),
|
50
|
+
UNIQUE KEY `index_users_on_pw_reset_code` (`pw_reset_code`),
|
51
|
+
KEY `index_users_on_activation_key` (`activation_key`),
|
52
|
+
KEY `index_users_on_activated` (`activated`),
|
53
|
+
KEY `index_users_on_last_name` (`last_name`)
|
54
|
+
) ENGINE=InnoDB AUTO_INCREMENT=919492 DEFAULT CHARSET=latin1;
|
55
|
+
/*!40101 SET character_set_client = @saved_cs_client */;
|
56
|
+
|
57
|
+
LOCK TABLES `users` WRITE;
|
58
|
+
/*!40000 ALTER TABLE `users` DISABLE KEYS */;
|
59
|
+
INSERT INTO `users` (`id`, `login`, `email`, `encrypted_password`, `password_salt`, `created_at`, `updated_at`, `remember_token`, `remember_token_expires_at`, `confirmed_agreement`, `first_name`, `middle_name`, `last_name`, `role`, `status`, `pw_reset_code`, `activated`, `activation_key`, `telephone`, `confirmed_referral_terms`, `confirmed_referral_terms_at`, `current_facility_id`, `selected_drive_id`, `triggers_qc`, `persistence_token`, `single_access_token`, `requires_ldap_authentication`, `sign_in_count`, `current_sign_in_at`, `last_sign_in_at`, `current_sign_in_ip`, `last_sign_in_ip`) VALUES (1,'jimmy@example.com','jimmy@example.com','937777777777e4077eacdd785afb55c5aac35d0e','937777777777e4077eacdd785afb55c5aac35d0e','2007-01-12 07:49:00','2009-05-20 18:43:04',NULL,NULL,0,'James','P','McElhiney',4,0,NULL,1,'937777777777e4077eacdd785afb55c5aac35d0e',NULL,1,'2009-02-16 20:03:34',1,NULL,0,NULL,NULL,0,0,NULL,NULL,NULL,NULL),(9,'shari@secondrotation.com','shari@secondrotation.com','937777777777e4077eacdd785afb55c5aac35d0e','937777777777e4077eacdd785afb55c5aac35d0e','2007-01-20 20:19:21','2008-07-28 00:38:27',NULL,NULL,0,'Jimmy','','Shivers',4,0,'937777777777e4077eacdd785afb55c5aac35d0e',1,'937777777777e4077eacdd785afb55c5aac35d0e',NULL,0,'2008-07-28 00:33:35',NULL,NULL,0,NULL,NULL,0,0,NULL,NULL,NULL,NULL);
|
60
|
+
/*!40000 ALTER TABLE `users` ENABLE KEYS */;
|
61
|
+
UNLOCK TABLES;
|
62
|
+
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
|
63
|
+
|
64
|
+
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
|
65
|
+
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
|
66
|
+
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
|
67
|
+
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
|
68
|
+
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
|
69
|
+
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
70
|
+
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
71
|
+
|
@@ -0,0 +1,115 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DumpTruck::Mysql::Translator do
|
4
|
+
let(:translator){DumpTruck::Mysql::Translator.new}
|
5
|
+
|
6
|
+
describe '#table?' do
|
7
|
+
context "when line contains table create" do
|
8
|
+
let(:line){"CREATE TABLE `roles` (\n"}
|
9
|
+
|
10
|
+
it 'returns truthy' do
|
11
|
+
expect(translator).to be_table(line)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
context "when line doesn't contain table create" do
|
16
|
+
let(:line){") ENGINE=InnoDB AUTO_INCREMENT=94 DEFAULT CHARSET=utf8;\n"}
|
17
|
+
|
18
|
+
it 'returns falsey' do
|
19
|
+
expect(translator).to_not be_table(line)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe '#extract_table' do
|
25
|
+
context "when line contains table create" do
|
26
|
+
let(:line){"CREATE TABLE `roles` (\n"}
|
27
|
+
|
28
|
+
it 'extracts the table name' do
|
29
|
+
expect(translator.extract_table(line)).to eq('roles')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
context "when line doesn't contain table create" do
|
34
|
+
let(:line){") ENGINE=InnoDB AUTO_INCREMENT=94 DEFAULT CHARSET=utf8;\n"}
|
35
|
+
|
36
|
+
it 'returns nil' do
|
37
|
+
expect(translator.extract_table(line)).to be_nil
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
describe '#insert?' do
|
43
|
+
context "when line contains insert" do
|
44
|
+
let(:line){"INSERT INTO `roles` (`id`, `name`, `description`, `created_at`, `updated_at`) VALUES (1,'Employee',NULL,'2009-08-11 11:10:17','2009-08-11 11:10:17');\n"}
|
45
|
+
|
46
|
+
it 'returns truthy' do
|
47
|
+
expect(translator).to be_insert(line)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
context "when line doesn't contain insert" do
|
52
|
+
let(:line){") ENGINE=InnoDB AUTO_INCREMENT=94 DEFAULT CHARSET=utf8;\n"}
|
53
|
+
|
54
|
+
it 'returns falsey' do
|
55
|
+
expect(translator).to_not be_insert(line)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#extract_insert' do
|
61
|
+
context 'with typical example' do
|
62
|
+
let(:line){"INSERT INTO `roles` (`id`, `name`, `description`, `created_at`, `updated_at`) VALUES (1,'Employee',NULL,'2009-08-11 11:10:17','2009-08-11 11:10:17');\n"}
|
63
|
+
|
64
|
+
it 'extracts the fields and values' do
|
65
|
+
expect(translator.extract_insert(line)).to eq([
|
66
|
+
%w(id name description created_at updated_at),
|
67
|
+
[{
|
68
|
+
'id' => 1,
|
69
|
+
'name' => 'Employee',
|
70
|
+
'description' => nil,
|
71
|
+
'created_at' => '2009-08-11 11:10:17',
|
72
|
+
'updated_at' => '2009-08-11 11:10:17'
|
73
|
+
}]
|
74
|
+
])
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
context 'with special cases' do
|
79
|
+
let(:line){"INSERT INTO `special_cases` (`contains_escaped_quote`, `empty_string`, `escapes_slash_before_quote`, `negative_number`, `negative_float`) VALUES ('\\'','','\\\\',-1,-1.3);\n"}
|
80
|
+
|
81
|
+
it 'extracts the fields and values' do
|
82
|
+
expect(translator.extract_insert(line)).to eq([
|
83
|
+
%w(contains_escaped_quote empty_string escapes_slash_before_quote negative_number negative_float),
|
84
|
+
[{
|
85
|
+
'contains_escaped_quote' => "\\'",
|
86
|
+
'empty_string' => '',
|
87
|
+
'escapes_slash_before_quote' => "\\\\",
|
88
|
+
'negative_number' => -1,
|
89
|
+
'negative_float' => -1.3
|
90
|
+
}]
|
91
|
+
])
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
describe '#generate_insert' do
|
97
|
+
let(:table){'roles'}
|
98
|
+
let(:keys){%w(id name description created_at updated_at)}
|
99
|
+
let(:data) do
|
100
|
+
[{
|
101
|
+
'id' => 1,
|
102
|
+
'name' => 'Employee',
|
103
|
+
'description' => nil,
|
104
|
+
'created_at' => '2009-08-11 11:10:17',
|
105
|
+
'updated_at' => '2009-08-11 11:10:17'
|
106
|
+
}]
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'generates a valid insert line' do
|
110
|
+
expect(translator.generate_insert(table, keys, data)).to eq(
|
111
|
+
"INSERT INTO `roles` (`id`, `name`, `description`, `created_at`, `updated_at`) VALUES (1,'Employee',NULL,'2009-08-11 11:10:17','2009-08-11 11:10:17');\n"
|
112
|
+
)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DumpTruck::SchemaConfiguration do
|
4
|
+
describe '.new' do
|
5
|
+
let(:config) do
|
6
|
+
DumpTruck::SchemaConfiguration.new('app_production') do
|
7
|
+
target_path '/home/jake/dumps'
|
8
|
+
target_name{|schema| schema + Time.at(0).strftime("_%Y%m%d%H%M%S")}
|
9
|
+
|
10
|
+
table(:users){}
|
11
|
+
end
|
12
|
+
end
|
13
|
+
subject{config}
|
14
|
+
|
15
|
+
its(:name){should eq('app_production')}
|
16
|
+
its(:target){should eq('/home/jake/dumps/app_production_19691231190000.sql.gz')}
|
17
|
+
its(:table_default){should eq(DumpTruck::TableConfiguration.new{truncate})}
|
18
|
+
its(:tables){should eq([DumpTruck::TableConfiguration.new(:users)])}
|
19
|
+
end
|
20
|
+
|
21
|
+
describe '#table_config_for' do
|
22
|
+
context 'with no table configuration' do
|
23
|
+
let(:config) do
|
24
|
+
DumpTruck::SchemaConfiguration.new('app_production')
|
25
|
+
end
|
26
|
+
|
27
|
+
it "uses the default table config" do
|
28
|
+
expect(config.table_config_for('cats')).to eq(config.table_default)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'with table config specified' do
|
33
|
+
let(:config) do
|
34
|
+
DumpTruck::SchemaConfiguration.new('app_production') do
|
35
|
+
table(:users){}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'uses the specified table config' do
|
40
|
+
expect(config.table_config_for(:users)).to eq(DumpTruck::TableConfiguration.new(:users))
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
2
|
+
require 'dump_truck'
|
3
|
+
require 'pry'
|
4
|
+
|
5
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
6
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
7
|
+
# Require this file using `require "spec_helper"` to ensure that it is only
|
8
|
+
# loaded once.
|
9
|
+
#
|
10
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
11
|
+
RSpec.configure do |config|
|
12
|
+
config.treat_symbols_as_metadata_keys_with_true_values = true
|
13
|
+
config.run_all_when_everything_filtered = true
|
14
|
+
config.filter_run :focus
|
15
|
+
|
16
|
+
# Run specs in random order to surface order dependencies. If you find an
|
17
|
+
# order dependency and want to debug it, you can fix the order by providing
|
18
|
+
# the seed, which is printed after each run.
|
19
|
+
# --seed 1234
|
20
|
+
config.order = 'random'
|
21
|
+
end
|