5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/global_uid/migration_extension.rb', line 5
def create_table(name, options = {}, &blk)
uid_enabled = GlobalUid.enabled? && options[:use_global_uid] != false
remove_auto_increment = uid_enabled && !(options[:id] == false)
options.merge!(:id => false) if remove_auto_increment
super(name, **options) { |t|
t.column :id, "int(10) NOT NULL PRIMARY KEY" if remove_auto_increment
blk.call(t) if blk
}
if uid_enabled
id_table_name = options[:global_uid_table] || GlobalUid::Base.id_table_from_name(name)
GlobalUid::Base.with_servers do |server|
server.create_uid_table!(
name: id_table_name,
uid_type: options[:uid_type],
start_id: options[:start_id]
)
end
end
end
|