fresh_connection 0.1.8 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/Appraisals +17 -0
  4. data/README.md +72 -8
  5. data/Rakefile +5 -0
  6. data/fresh_connection.gemspec +6 -1
  7. data/gemfiles/rails3.gemfile +9 -0
  8. data/gemfiles/rails40.gemfile +9 -0
  9. data/gemfiles/rails41.gemfile +9 -0
  10. data/lib/fresh_connection.rb +39 -9
  11. data/lib/fresh_connection/abstract_connection_manager.rb +4 -1
  12. data/lib/fresh_connection/access_control.rb +56 -0
  13. data/lib/fresh_connection/connection_manager.rb +2 -2
  14. data/lib/fresh_connection/extend/ar_base.rb +47 -0
  15. data/lib/fresh_connection/extend/ar_relation.rb +44 -0
  16. data/lib/fresh_connection/extend/connection_handler.rb +16 -0
  17. data/lib/fresh_connection/extend/mysql2_adapter.rb +46 -0
  18. data/lib/fresh_connection/initializer.rb +35 -0
  19. data/lib/fresh_connection/rack/connection_management.rb +1 -1
  20. data/lib/fresh_connection/railtie.rb +7 -4
  21. data/lib/fresh_connection/slave_connection.rb +29 -65
  22. data/lib/fresh_connection/slave_connection_handler.rb +43 -0
  23. data/lib/fresh_connection/version.rb +1 -1
  24. data/log/.gitkeep +0 -0
  25. data/spec/database.yml +14 -0
  26. data/spec/db_schema.sql +291 -0
  27. data/spec/prepare.rb +33 -0
  28. data/spec/spec_helper.rb +8 -0
  29. data/spec/support/active_record_logger.rb +3 -0
  30. data/spec/unit/access_control_spec.rb +63 -0
  31. data/spec/unit/ar_base_spec.rb +42 -0
  32. data/spec/unit/fresh_connection_spec.rb +106 -0
  33. data/spec/unit/recovery_spec.rb +39 -0
  34. metadata +154 -81
  35. data/lib/fresh_connection/active_record/abstract_adapter.rb +0 -35
  36. data/lib/fresh_connection/active_record/mysql2_adapter.rb +0 -14
  37. data/lib/fresh_connection/active_record/relation.rb +0 -33
@@ -0,0 +1,46 @@
1
+ module FreshConnection
2
+ module Extend
3
+ module Mysql2Adapter
4
+ def self.included(base)
5
+ base.__send__(:attr_writer, :model_class)
6
+ base.alias_method_chain :configure_connection, :fresh_connection
7
+ end
8
+
9
+ def select_all(arel, name = nil, binds = [])
10
+ if FreshConnection::AccessControl.slave_access?
11
+ change_connection do
12
+ super(arel, "[#{@model_class.slave_group}] #{name}", binds)
13
+ end
14
+ else
15
+ super
16
+ end
17
+ end
18
+
19
+ private
20
+
21
+ def change_connection
22
+ retry_count = 0
23
+ master_connection = @connection
24
+ begin
25
+ slave_connection = @model_class.slave_connection
26
+ @connection = slave_connection.raw_connection
27
+ yield
28
+ rescue ActiveRecord::StatementInvalid => exception
29
+ if @model_class.recovery(slave_connection, exception)
30
+ retry_count += 1
31
+ retry if retry_count < FreshConnection.retry_limit
32
+ end
33
+
34
+ raise
35
+ end
36
+ ensure
37
+ @connection = master_connection
38
+ end
39
+
40
+ def configure_connection_with_fresh_connection
41
+ return if FreshConnection.ignore_configure_connection?
42
+ configure_connection_without_fresh_connection
43
+ end
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,35 @@
1
+ require 'active_record/connection_adapters/mysql2_adapter'
2
+ require 'fresh_connection/rack/connection_management'
3
+ require 'fresh_connection/extend/ar_base'
4
+ require 'fresh_connection/extend/ar_relation'
5
+ require 'fresh_connection/extend/connection_handler'
6
+ require 'fresh_connection/extend/mysql2_adapter'
7
+
8
+ module FreshConnection
9
+ class Initializer
10
+ class << self
11
+ def swap_rack(app)
12
+ app.config.middleware.swap(
13
+ ActiveRecord::ConnectionAdapters::ConnectionManagement,
14
+ FreshConnection::Rack::ConnectionManagement
15
+ )
16
+ end
17
+
18
+ def extend_active_record
19
+ ActiveRecord::Base.extend FreshConnection::Extend::ArBase
20
+
21
+ ActiveRecord::Relation.__send__(:include, FreshConnection::Extend::ArRelation)
22
+
23
+ ActiveRecord::ConnectionAdapters::ConnectionHandler.__send__(
24
+ :include, FreshConnection::Extend::ConnectionHandler
25
+ )
26
+
27
+ ActiveRecord::ConnectionAdapters::Mysql2Adapter.__send__(
28
+ :include, FreshConnection::Extend::Mysql2Adapter
29
+ )
30
+
31
+ ActiveRecord::Base.establish_fresh_connection
32
+ end
33
+ end
34
+ end
35
+ end
@@ -4,7 +4,7 @@ module FreshConnection
4
4
  def call(env)
5
5
  super
6
6
  ensure
7
- FreshConnection::SlaveConnection.put_aside! unless env.key?("rack.test")
7
+ ActiveRecord::Base.put_aside! unless env.key?("rack.test")
8
8
  end
9
9
  end
10
10
  end
@@ -1,10 +1,13 @@
1
+ require 'rails'
2
+
1
3
  module FreshConnection
2
4
  class Railtie < Rails::Railtie
3
5
  initializer "fresh_connection.configure_rails_initialization" do |app|
4
- app.config.middleware.swap(
5
- ActiveRecord::ConnectionAdapters::ConnectionManagement,
6
- FreshConnection::Rack::ConnectionManagement
7
- )
6
+ Initializer.swap_rack(app)
7
+
8
+ ActiveSupport.on_load(:active_record) do
9
+ Initializer.extend_active_record
10
+ end
8
11
  end
9
12
  end
10
13
  end
@@ -1,89 +1,53 @@
1
+ require 'active_support/deprecation'
2
+
1
3
  module FreshConnection
4
+ #
5
+ # This class has been deprecated.
6
+ # It will delete at next version.
7
+ #
2
8
  class SlaveConnection
3
- COUNT = :fresh_connection_access_count
4
- TARGET = :fresh_connection_access_target
5
- RETRY_LIMIT = 10
6
-
7
9
  class << self
8
- attr_writer :ignore_models, :ignore_configure_connection
9
-
10
- delegate :slave_connection, :put_aside!, :recoverable?, :recovery, :to => :connection_manager
11
-
12
- def manage_access(model_klass, go_slave, &block)
13
- if ignore_model?(model_klass)
14
- force_master_access(&block)
15
- else
16
- target = go_slave ? :slave : :master
17
- begin
18
- access_in(target)
19
- block.call
20
- ensure
21
- access_out
10
+ def ignore_models=(models)
11
+ deprecation("ignore_models=", "ActiveRecord::Base.master_db_only!")
12
+ models.each do |model|
13
+ if model.is_a?(String)
14
+ model.constantize.master_db_only!
15
+ elsif model.ancestors.include?(ActiveRecord::Base)
16
+ model.master_db_only!
22
17
  end
23
18
  end
24
19
  end
25
20
 
26
- def slave_access?
27
- Thread.current[TARGET] == :slave
28
- end
29
-
30
- def ignore_model?(model_klass)
31
- @cached_ignore_model ||= {}
32
- return @cached_ignore_model[model_klass] if @cached_ignore_model.has_key?(model_klass)
33
-
34
- @cached_ignore_model[model_klass] = check_ignore_model(model_klass)
35
- end
36
-
37
- def ignore_configure_connection?
38
- !!@ignore_configure_connection
21
+ def ignore_configure_connection=(flag)
22
+ deprecation("ignore_configure_connection=", "FreshConnection.ignore_configure_connection=")
23
+ FreshConnection.ignore_configure_connection = flag
39
24
  end
40
25
 
41
26
  def connection_manager=(manager)
42
- @connection_manager_class = manager
27
+ deprecation("connection_manager=", "FreshConnection.connection_manager=")
28
+ FreshConnection.connection_manager = manager
43
29
  end
44
30
 
45
- def retry_limit
46
- RETRY_LIMIT
31
+ def slave_connection
32
+ raise_deprecation_exception("slave_connection", "ArtiveRecord::Base.slave_connection")
47
33
  end
48
34
 
49
35
  private
50
36
 
51
- def force_master_access
52
- now_target = Thread.current[TARGET]
53
- Thread.current[TARGET] = :master
54
- yield
55
- ensure
56
- Thread.current[TARGET] = now_target
57
- end
58
-
59
- def access_in(target)
60
- Thread.current[COUNT] = (Thread.current[COUNT] || 0) + 1
61
- Thread.current[TARGET] ||= target
37
+ def deprecation(method_name, instead_method)
38
+ ActiveSupport::Deprecation.warn(deprecation_message(method_name, instead_method))
62
39
  end
63
40
 
64
- def access_out
65
- Thread.current[COUNT] -= 1
66
- if Thread.current[COUNT] == 0
67
- Thread.current[TARGET] = nil
68
- Thread.current[COUNT] = nil
41
+ def raise_deprecation_exception(method_name, instead_method)
42
+ if defined?(ActiveSupport::DeprecationException)
43
+ raise ActiveSupport::DeprecationException, deprecation_message(method_name, instead_method)
44
+ else
45
+ raise "ActiveSupport::DeprecationException: #{deprecation_message(method_name, instead_method)}"
69
46
  end
70
47
  end
71
48
 
72
- def connection_manager
73
- @connection_manager ||=
74
- (@connection_manager_class || FreshConnection::ConnectionManager).new
75
- end
76
-
77
- def check_ignore_model(model_klass)
78
- (@ignore_models || []).one? do |ignore_model|
79
- if ignore_model.is_a?(String)
80
- ignore_model == model_klass.name
81
- elsif ignore_model.ancestors.include?(ActiveRecord::Base)
82
- model_klass.ancestors.include?(ignore_model)
83
- else
84
- false
85
- end
86
- end
49
+ def deprecation_message(method_name, instead_method)
50
+ "FreshConnection::SlaveConnection.#{method_name} has been deprecated. Use #{instead_method} instead"
87
51
  end
88
52
  end
89
53
  end
@@ -0,0 +1,43 @@
1
+ module FreshConnection
2
+ class SlaveConnectionHandler
3
+ def initialize
4
+ @class_to_pool = {}
5
+ end
6
+
7
+ def establish_connection(name, slave_group)
8
+ if cm = @class_to_pool[name]
9
+ cm.put_aside!
10
+ end
11
+
12
+ @class_to_pool[name] = FreshConnection.connection_manager.new(slave_group)
13
+ end
14
+
15
+ def connection(klass)
16
+ detect_connection_manager(klass).slave_connection
17
+ end
18
+
19
+ def put_aside!
20
+ @class_to_pool.values.each do |connection_manager|
21
+ connection_manager.put_aside!
22
+ end
23
+ end
24
+
25
+ def recovery(klass, failure_connection, exception)
26
+ detect_connection_manager(klass).recovery(failure_connection, exception)
27
+ end
28
+
29
+ def slave_group(klass)
30
+ detect_connection_manager(klass).slave_group
31
+ end
32
+
33
+ private
34
+
35
+ def detect_connection_manager(klass)
36
+ c = @class_to_pool[klass.name]
37
+ return c if c
38
+ return nil if ActiveRecord::Base == klass
39
+ detect_connection_manager(klass.superclass)
40
+ end
41
+ end
42
+ end
43
+
@@ -1,4 +1,4 @@
1
1
  module FreshConnection
2
- VERSION = "0.1.8"
2
+ VERSION = "0.2.0"
3
3
  end
4
4
 
data/log/.gitkeep ADDED
File without changes
data/spec/database.yml ADDED
@@ -0,0 +1,14 @@
1
+ test:
2
+ adapter: mysql2
3
+ encoding: utf8
4
+ database: fresh_connection_test_master
5
+ pool: 5
6
+ username: root
7
+ password:
8
+
9
+ slave1:
10
+ database: fresh_connection_test_slave1
11
+
12
+ slave2:
13
+ database: fresh_connection_test_slave2
14
+
@@ -0,0 +1,291 @@
1
+ -- MySQL dump 10.13 Distrib 5.6.15, for osx10.9 (x86_64)
2
+ --
3
+ -- Host: localhost Database: fresh_connection_test_master
4
+ -- ------------------------------------------------------
5
+ -- Server version 5.6.15
6
+
7
+ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
8
+ /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
9
+ /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
10
+ /*!40101 SET NAMES utf8 */;
11
+ /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
12
+ /*!40103 SET TIME_ZONE='+00:00' */;
13
+ /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
14
+ /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
15
+ /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
16
+ /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
17
+
18
+ --
19
+ -- Current Database: `fresh_connection_test_master`
20
+ --
21
+
22
+ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `fresh_connection_test_master` /*!40100 DEFAULT CHARACTER SET utf8 */;
23
+
24
+ USE `fresh_connection_test_master`;
25
+
26
+ --
27
+ -- Table structure for table `addresses`
28
+ --
29
+
30
+ DROP TABLE IF EXISTS `addresses`;
31
+ /*!40101 SET @saved_cs_client = @@character_set_client */;
32
+ /*!40101 SET character_set_client = utf8 */;
33
+ CREATE TABLE `addresses` (
34
+ `id` int(11) NOT NULL AUTO_INCREMENT,
35
+ `user_id` int(11) NOT NULL DEFAULT '0',
36
+ `prefecture` varchar(255) NOT NULL DEFAULT '',
37
+ `created_at` datetime DEFAULT NULL,
38
+ `updated_at` datetime DEFAULT NULL,
39
+ PRIMARY KEY (`id`)
40
+ ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
41
+ /*!40101 SET character_set_client = @saved_cs_client */;
42
+
43
+ --
44
+ -- Dumping data for table `addresses`
45
+ --
46
+
47
+ LOCK TABLES `addresses` WRITE;
48
+ /*!40000 ALTER TABLE `addresses` DISABLE KEYS */;
49
+ INSERT INTO `addresses` VALUES (1,1,'Tokyo (master)','2014-04-10 07:24:16','2014-04-10 07:24:16');
50
+ /*!40000 ALTER TABLE `addresses` ENABLE KEYS */;
51
+ UNLOCK TABLES;
52
+
53
+ --
54
+ -- Table structure for table `tels`
55
+ --
56
+
57
+ DROP TABLE IF EXISTS `tels`;
58
+ /*!40101 SET @saved_cs_client = @@character_set_client */;
59
+ /*!40101 SET character_set_client = utf8 */;
60
+ CREATE TABLE `tels` (
61
+ `id` int(11) NOT NULL AUTO_INCREMENT,
62
+ `user_id` int(11) NOT NULL DEFAULT '0',
63
+ `number` varchar(255) NOT NULL DEFAULT '',
64
+ `created_at` datetime DEFAULT NULL,
65
+ `updated_at` datetime DEFAULT NULL,
66
+ PRIMARY KEY (`id`)
67
+ ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
68
+ /*!40101 SET character_set_client = @saved_cs_client */;
69
+
70
+ --
71
+ -- Dumping data for table `tels`
72
+ --
73
+
74
+ LOCK TABLES `tels` WRITE;
75
+ /*!40000 ALTER TABLE `tels` DISABLE KEYS */;
76
+ INSERT INTO `tels` VALUES (1,1,'03-1111-1111 (master)','2014-04-10 07:24:16','2014-04-10 07:24:16'),(2,1,'03-1111-1112 (master)','2014-04-10 07:24:16','2014-04-10 07:24:16'),(3,1,'03-1111-1113 (master)','2014-04-10 07:24:16','2014-04-10 07:24:16');
77
+ /*!40000 ALTER TABLE `tels` ENABLE KEYS */;
78
+ UNLOCK TABLES;
79
+
80
+ --
81
+ -- Table structure for table `users`
82
+ --
83
+
84
+ DROP TABLE IF EXISTS `users`;
85
+ /*!40101 SET @saved_cs_client = @@character_set_client */;
86
+ /*!40101 SET character_set_client = utf8 */;
87
+ CREATE TABLE `users` (
88
+ `id` int(11) NOT NULL AUTO_INCREMENT,
89
+ `name` varchar(255) NOT NULL DEFAULT '',
90
+ `created_at` datetime DEFAULT NULL,
91
+ `updated_at` datetime DEFAULT NULL,
92
+ PRIMARY KEY (`id`)
93
+ ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
94
+ /*!40101 SET character_set_client = @saved_cs_client */;
95
+
96
+ --
97
+ -- Dumping data for table `users`
98
+ --
99
+
100
+ LOCK TABLES `users` WRITE;
101
+ /*!40000 ALTER TABLE `users` DISABLE KEYS */;
102
+ INSERT INTO `users` VALUES (1,'Tsukasa (master)','2014-04-10 07:24:16','2014-04-10 07:24:16');
103
+ /*!40000 ALTER TABLE `users` ENABLE KEYS */;
104
+ UNLOCK TABLES;
105
+
106
+ --
107
+ -- Current Database: `fresh_connection_test_slave1`
108
+ --
109
+
110
+ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `fresh_connection_test_slave1` /*!40100 DEFAULT CHARACTER SET utf8 */;
111
+
112
+ USE `fresh_connection_test_slave1`;
113
+
114
+ --
115
+ -- Table structure for table `addresses`
116
+ --
117
+
118
+ DROP TABLE IF EXISTS `addresses`;
119
+ /*!40101 SET @saved_cs_client = @@character_set_client */;
120
+ /*!40101 SET character_set_client = utf8 */;
121
+ CREATE TABLE `addresses` (
122
+ `id` int(11) NOT NULL AUTO_INCREMENT,
123
+ `user_id` int(11) NOT NULL DEFAULT '0',
124
+ `prefecture` varchar(255) NOT NULL DEFAULT '',
125
+ `created_at` datetime DEFAULT NULL,
126
+ `updated_at` datetime DEFAULT NULL,
127
+ PRIMARY KEY (`id`)
128
+ ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
129
+ /*!40101 SET character_set_client = @saved_cs_client */;
130
+
131
+ --
132
+ -- Dumping data for table `addresses`
133
+ --
134
+
135
+ LOCK TABLES `addresses` WRITE;
136
+ /*!40000 ALTER TABLE `addresses` DISABLE KEYS */;
137
+ INSERT INTO `addresses` VALUES (1,1,'Tokyo (slave1)','2014-04-10 07:24:16','2014-04-10 07:24:16');
138
+ /*!40000 ALTER TABLE `addresses` ENABLE KEYS */;
139
+ UNLOCK TABLES;
140
+
141
+ --
142
+ -- Table structure for table `tels`
143
+ --
144
+
145
+ DROP TABLE IF EXISTS `tels`;
146
+ /*!40101 SET @saved_cs_client = @@character_set_client */;
147
+ /*!40101 SET character_set_client = utf8 */;
148
+ CREATE TABLE `tels` (
149
+ `id` int(11) NOT NULL AUTO_INCREMENT,
150
+ `user_id` int(11) NOT NULL DEFAULT '0',
151
+ `number` varchar(255) NOT NULL DEFAULT '',
152
+ `created_at` datetime DEFAULT NULL,
153
+ `updated_at` datetime DEFAULT NULL,
154
+ PRIMARY KEY (`id`)
155
+ ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
156
+ /*!40101 SET character_set_client = @saved_cs_client */;
157
+
158
+ --
159
+ -- Dumping data for table `tels`
160
+ --
161
+
162
+ LOCK TABLES `tels` WRITE;
163
+ /*!40000 ALTER TABLE `tels` DISABLE KEYS */;
164
+ INSERT INTO `tels` VALUES (1,1,'03-1111-1111 (slave1)','2014-04-10 07:24:16','2014-04-10 07:24:16'),(2,1,'03-1111-1112 (slave1)','2014-04-10 07:24:16','2014-04-10 07:24:16'),(3,1,'03-1111-1113 (slave1)','2014-04-10 07:24:16','2014-04-10 07:24:16');
165
+ /*!40000 ALTER TABLE `tels` ENABLE KEYS */;
166
+ UNLOCK TABLES;
167
+
168
+ --
169
+ -- Table structure for table `users`
170
+ --
171
+
172
+ DROP TABLE IF EXISTS `users`;
173
+ /*!40101 SET @saved_cs_client = @@character_set_client */;
174
+ /*!40101 SET character_set_client = utf8 */;
175
+ CREATE TABLE `users` (
176
+ `id` int(11) NOT NULL AUTO_INCREMENT,
177
+ `name` varchar(255) NOT NULL DEFAULT '',
178
+ `created_at` datetime DEFAULT NULL,
179
+ `updated_at` datetime DEFAULT NULL,
180
+ PRIMARY KEY (`id`)
181
+ ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
182
+ /*!40101 SET character_set_client = @saved_cs_client */;
183
+
184
+ --
185
+ -- Dumping data for table `users`
186
+ --
187
+
188
+ LOCK TABLES `users` WRITE;
189
+ /*!40000 ALTER TABLE `users` DISABLE KEYS */;
190
+ INSERT INTO `users` VALUES (1,'Tsukasa (slave1)','2014-04-10 07:24:16','2014-04-10 07:24:16');
191
+ /*!40000 ALTER TABLE `users` ENABLE KEYS */;
192
+ UNLOCK TABLES;
193
+
194
+ --
195
+ -- Current Database: `fresh_connection_test_slave2`
196
+ --
197
+
198
+ CREATE DATABASE /*!32312 IF NOT EXISTS*/ `fresh_connection_test_slave2` /*!40100 DEFAULT CHARACTER SET utf8 */;
199
+
200
+ USE `fresh_connection_test_slave2`;
201
+
202
+ --
203
+ -- Table structure for table `addresses`
204
+ --
205
+
206
+ DROP TABLE IF EXISTS `addresses`;
207
+ /*!40101 SET @saved_cs_client = @@character_set_client */;
208
+ /*!40101 SET character_set_client = utf8 */;
209
+ CREATE TABLE `addresses` (
210
+ `id` int(11) NOT NULL AUTO_INCREMENT,
211
+ `user_id` int(11) NOT NULL DEFAULT '0',
212
+ `prefecture` varchar(255) NOT NULL DEFAULT '',
213
+ `created_at` datetime DEFAULT NULL,
214
+ `updated_at` datetime DEFAULT NULL,
215
+ PRIMARY KEY (`id`)
216
+ ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
217
+ /*!40101 SET character_set_client = @saved_cs_client */;
218
+
219
+ --
220
+ -- Dumping data for table `addresses`
221
+ --
222
+
223
+ LOCK TABLES `addresses` WRITE;
224
+ /*!40000 ALTER TABLE `addresses` DISABLE KEYS */;
225
+ INSERT INTO `addresses` VALUES (1,1,'Tokyo (slave2)','2014-04-10 07:24:16','2014-04-10 07:24:16');
226
+ /*!40000 ALTER TABLE `addresses` ENABLE KEYS */;
227
+ UNLOCK TABLES;
228
+
229
+ --
230
+ -- Table structure for table `tels`
231
+ --
232
+
233
+ DROP TABLE IF EXISTS `tels`;
234
+ /*!40101 SET @saved_cs_client = @@character_set_client */;
235
+ /*!40101 SET character_set_client = utf8 */;
236
+ CREATE TABLE `tels` (
237
+ `id` int(11) NOT NULL AUTO_INCREMENT,
238
+ `user_id` int(11) NOT NULL DEFAULT '0',
239
+ `number` varchar(255) NOT NULL DEFAULT '',
240
+ `created_at` datetime DEFAULT NULL,
241
+ `updated_at` datetime DEFAULT NULL,
242
+ PRIMARY KEY (`id`)
243
+ ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8;
244
+ /*!40101 SET character_set_client = @saved_cs_client */;
245
+
246
+ --
247
+ -- Dumping data for table `tels`
248
+ --
249
+
250
+ LOCK TABLES `tels` WRITE;
251
+ /*!40000 ALTER TABLE `tels` DISABLE KEYS */;
252
+ INSERT INTO `tels` VALUES (1,1,'03-1111-1111 (slave2)','2014-04-10 07:24:16','2014-04-10 07:24:16'),(2,1,'03-1111-1112 (slave2)','2014-04-10 07:24:16','2014-04-10 07:24:16'),(3,1,'03-1111-1113 (slave2)','2014-04-10 07:24:16','2014-04-10 07:24:16');
253
+ /*!40000 ALTER TABLE `tels` ENABLE KEYS */;
254
+ UNLOCK TABLES;
255
+
256
+ --
257
+ -- Table structure for table `users`
258
+ --
259
+
260
+ DROP TABLE IF EXISTS `users`;
261
+ /*!40101 SET @saved_cs_client = @@character_set_client */;
262
+ /*!40101 SET character_set_client = utf8 */;
263
+ CREATE TABLE `users` (
264
+ `id` int(11) NOT NULL AUTO_INCREMENT,
265
+ `name` varchar(255) NOT NULL DEFAULT '',
266
+ `created_at` datetime DEFAULT NULL,
267
+ `updated_at` datetime DEFAULT NULL,
268
+ PRIMARY KEY (`id`)
269
+ ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
270
+ /*!40101 SET character_set_client = @saved_cs_client */;
271
+
272
+ --
273
+ -- Dumping data for table `users`
274
+ --
275
+
276
+ LOCK TABLES `users` WRITE;
277
+ /*!40000 ALTER TABLE `users` DISABLE KEYS */;
278
+ INSERT INTO `users` VALUES (1,'Tsukasa (slave2)','2014-04-10 07:24:16','2014-04-10 07:24:16');
279
+ /*!40000 ALTER TABLE `users` ENABLE KEYS */;
280
+ UNLOCK TABLES;
281
+ /*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
282
+
283
+ /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
284
+ /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
285
+ /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
286
+ /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
287
+ /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
288
+ /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
289
+ /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
290
+
291
+ -- Dump completed on 2014-04-10 21:36:33