self.table_name = "push_event_trackings1"
def self.for account_id
tname = "push_event_trackings#{account_id}"
model_name = tname.classify
if Object.const_defined?(model_name)
fields_class = model_name.constantize
else
fields_class = Object.const_set(model_name, Class.new(PushTracking){
self.table_name = tname
})
end
return fields_class.using(:sms)
end
def self.create_table account_id
fields_table_name = "push_event_trackings#{account_id}"
Octopus.using(:sms) do
ActiveRecord::Migration.execute "CREATE TABLE `#{fields_table_name}` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`push_device_id` int(11) DEFAULT NULL,
`push_event_id` int(11) DEFAULT NULL,
`cart_id` int(11) DEFAULT NULL,
`sku` varchar(255) DEFAULT NULL,
`description` varchar(255) DEFAULT NULL,
`quantity` int(11) DEFAULT NULL,
`value` float DEFAULT NULL,
`product_category` varchar(255) DEFAULT NULL,
`brand` varchar(255) DEFAULT NULL,
`model_number` varchar(255) DEFAULT NULL,
`order_id` varchar(255) DEFAULT NULL,
`order_date` datetime DEFAULT NULL,
`order_status` varchar(255) DEFAULT NULL,
`coupon_code` varchar(255) DEFAULT NULL,
`campaign_id` int(11) DEFAULT NULL,
`session_id` int(11) DEFAULT NULL,
`platform` int(11) DEFAULT NULL,
`price` float DEFAULT NULL,
`content_id` int(11) DEFAULT NULL,
`title` varchar(255) DEFAULT NULL,
`category` varchar(255) DEFAULT NULL,
`event_data` text COLLATE utf8_unicode_ci,
`latitude` float DEFAULT NULL,
`longitude` float DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8"
ActiveRecord::Migration.add_index(fields_table_name, :push_device_id)
ActiveRecord::Migration.add_index(fields_table_name, :push_event_id)
end
end
run migration on console according to account id
account = Account.first
PushEvenTracking.create account.id
def self.for account_id
tname = "push_event_trackings#{account_id}"
model_name = tname.classify
if Object.const_defined?(model_name)
fields_class = model_name.constantize
else
fields_class = Object.const_set(model_name, Class.new(PushTracking){
self.table_name = tname
})
end
return fields_class.using(:sms)
end
def self.create_table account_id
fields_table_name = "push_event_trackings#{account_id}"
Octopus.using(:sms) do
ActiveRecord::Migration.execute "CREATE TABLE `#{fields_table_name}` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`push_device_id` int(11) DEFAULT NULL,
`push_event_id` int(11) DEFAULT NULL,
`cart_id` int(11) DEFAULT NULL,
`sku` varchar(255) DEFAULT NULL,
`description` varchar(255) DEFAULT NULL,
`quantity` int(11) DEFAULT NULL,
`value` float DEFAULT NULL,
`product_category` varchar(255) DEFAULT NULL,
`brand` varchar(255) DEFAULT NULL,
`model_number` varchar(255) DEFAULT NULL,
`order_id` varchar(255) DEFAULT NULL,
`order_date` datetime DEFAULT NULL,
`order_status` varchar(255) DEFAULT NULL,
`coupon_code` varchar(255) DEFAULT NULL,
`campaign_id` int(11) DEFAULT NULL,
`session_id` int(11) DEFAULT NULL,
`platform` int(11) DEFAULT NULL,
`price` float DEFAULT NULL,
`content_id` int(11) DEFAULT NULL,
`title` varchar(255) DEFAULT NULL,
`category` varchar(255) DEFAULT NULL,
`event_data` text COLLATE utf8_unicode_ci,
`latitude` float DEFAULT NULL,
`longitude` float DEFAULT NULL,
`created_at` datetime NOT NULL,
`updated_at` datetime NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8"
ActiveRecord::Migration.add_index(fields_table_name, :push_device_id)
ActiveRecord::Migration.add_index(fields_table_name, :push_event_id)
end
end
run migration on console according to account id
account = Account.first
PushEvenTracking.create account.id
Nice blog and absolutely outstanding. You can do something much better but i still say this perfect.Keep trying for the best. ROR Development Company India,
ReplyDeleteSeriously i am very much confuse while Creating migration with account wise. Your blog is very much useful for me. It enhanced my knowledge after reading your code and blog. Thank you for the information. I want to work on large Ruby on rails project so can you suggest me any Ruby on Rails Development Company?
ReplyDelete