dm_newsletter 4.2.1.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +33 -0
  4. data/Rakefile +30 -0
  5. data/app/assets/stylesheets/dm_newsletter/application.css +13 -0
  6. data/app/controllers/dm_newsletter/admin/admin_controller.rb +16 -0
  7. data/app/controllers/dm_newsletter/admin/newsletters_controller.rb +81 -0
  8. data/app/controllers/dm_newsletter/application_controller.rb +3 -0
  9. data/app/controllers/dm_newsletter/newsletters_controller.rb +50 -0
  10. data/app/helpers/dm_newsletter/newsletters_helper.rb +8 -0
  11. data/app/models/dm_newsletter/concerns/ability.rb +37 -0
  12. data/app/models/dm_newsletter/permitted_params.rb +20 -0
  13. data/app/models/mailchimp_newsletter.rb +217 -0
  14. data/app/models/mailchimp_newsletter_subscriber.rb +43 -0
  15. data/app/models/newsletter.rb +46 -0
  16. data/app/models/newsletter_subscriber.rb +257 -0
  17. data/app/models/standard_newsletter.rb +19 -0
  18. data/app/views/dm_newsletter/admin/newsletters/_form.html.erb +17 -0
  19. data/app/views/dm_newsletter/admin/newsletters/edit.html.erb +2 -0
  20. data/app/views/dm_newsletter/admin/newsletters/index.html.erb +32 -0
  21. data/app/views/dm_newsletter/admin/newsletters/new.html.erb +2 -0
  22. data/app/views/dm_newsletter/admin/newsletters/show.html.erb +46 -0
  23. data/config/locales/nms.cs.yml +15 -0
  24. data/config/locales/nms.de.yml +15 -0
  25. data/config/locales/nms.en.yml +15 -0
  26. data/config/locales/nms.fi.yml +15 -0
  27. data/config/locales/nms.ja.yml +15 -0
  28. data/config/routes.rb +15 -0
  29. data/db/20130730120724_create_subscribers.rb +32 -0
  30. data/db/migrate/20130729075442_create_newsletter.rb +24 -0
  31. data/lib/dm_newsletter.rb +4 -0
  32. data/lib/dm_newsletter/engine.rb +8 -0
  33. data/lib/tasks/dm_newsletter_tasks.rake +4 -0
  34. data/spec/dummy/README.rdoc +28 -0
  35. data/spec/dummy/Rakefile +6 -0
  36. data/spec/dummy/app/assets/javascripts/application.js +13 -0
  37. data/spec/dummy/app/assets/stylesheets/application.css +15 -0
  38. data/spec/dummy/app/controllers/application_controller.rb +5 -0
  39. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  40. data/spec/dummy/app/models/ability.rb +12 -0
  41. data/spec/dummy/app/models/user.rb +6 -0
  42. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  43. data/spec/dummy/bin/bundle +3 -0
  44. data/spec/dummy/bin/rails +4 -0
  45. data/spec/dummy/bin/rake +4 -0
  46. data/spec/dummy/config.ru +4 -0
  47. data/spec/dummy/config/application.rb +26 -0
  48. data/spec/dummy/config/boot.rb +5 -0
  49. data/spec/dummy/config/database.yml +25 -0
  50. data/spec/dummy/config/environment.rb +5 -0
  51. data/spec/dummy/config/environments/development.rb +37 -0
  52. data/spec/dummy/config/environments/production.rb +82 -0
  53. data/spec/dummy/config/environments/test.rb +39 -0
  54. data/spec/dummy/config/initializers/assets.rb +8 -0
  55. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  56. data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
  57. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  58. data/spec/dummy/config/initializers/inflections.rb +16 -0
  59. data/spec/dummy/config/initializers/mime_types.rb +4 -0
  60. data/spec/dummy/config/initializers/session_store.rb +3 -0
  61. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  62. data/spec/dummy/config/locales/en.yml +23 -0
  63. data/spec/dummy/config/routes.rb +12 -0
  64. data/spec/dummy/config/secrets.yml +22 -0
  65. data/spec/dummy/db/development.sqlite3 +0 -0
  66. data/spec/dummy/db/migrate/20141114170927_add_globalize_countries.dm_core.rb +50 -0
  67. data/spec/dummy/db/migrate/20141114170928_devise_create_users.dm_core.rb +46 -0
  68. data/spec/dummy/db/migrate/20141114170929_add_user_fields.dm_core.rb +14 -0
  69. data/spec/dummy/db/migrate/20141114170930_rolify_create_roles.dm_core.rb +20 -0
  70. data/spec/dummy/db/migrate/20141114170931_add_last_access.dm_core.rb +10 -0
  71. data/spec/dummy/db/migrate/20141114170932_create_versions.dm_core.rb +19 -0
  72. data/spec/dummy/db/migrate/20141114170933_add_object_changes_column_to_versions.dm_core.rb +12 -0
  73. data/spec/dummy/db/migrate/20141114170934_create_dm_core_accounts.dm_core.rb +13 -0
  74. data/spec/dummy/db/migrate/20141114170935_add_account_to_users.dm_core.rb +9 -0
  75. data/spec/dummy/db/migrate/20141114170936_create_preferences.dm_core.rb +13 -0
  76. data/spec/dummy/db/migrate/20141114170937_create_comments.dm_core.rb +22 -0
  77. data/spec/dummy/db/migrate/20141114170938_add_activity.dm_core.rb +21 -0
  78. data/spec/dummy/db/migrate/20141114170939_add_type_to_comments.dm_core.rb +9 -0
  79. data/spec/dummy/db/migrate/20141114170940_add_category.dm_core.rb +28 -0
  80. data/spec/dummy/db/migrate/20141114170941_create_email_table.dm_core.rb +26 -0
  81. data/spec/dummy/db/migrate/20141114170942_add_user_profile.dm_core.rb +46 -0
  82. data/spec/dummy/db/migrate/20141114170943_add_profile_email.dm_core.rb +14 -0
  83. data/spec/dummy/db/migrate/20141114170944_create_payment_history.dm_core.rb +37 -0
  84. data/spec/dummy/db/migrate/20141114170945_change_anchor_field.dm_core.rb +10 -0
  85. data/spec/dummy/db/migrate/20141114170946_create_user_site_profile.dm_core.rb +27 -0
  86. data/spec/dummy/db/migrate/20141114170947_add_avatar.dm_core.rb +12 -0
  87. data/spec/dummy/db/migrate/20141114170948_add_notify_to_payment_history.dm_core.rb +8 -0
  88. data/spec/dummy/db/migrate/20141114170949_acts_as_votable_migration.dm_core.rb +28 -0
  89. data/spec/dummy/db/migrate/20141114170950_add_user_site_profile_uuid.dm_core.rb +19 -0
  90. data/spec/dummy/db/migrate/20141114170951_add_invoice_id.dm_core.rb +7 -0
  91. data/spec/dummy/db/migrate/20141114170952_acts_as_follower_migration.dm_core.rb +18 -0
  92. data/spec/dummy/db/migrate/20141114170953_rename_invoice_id.dm_core.rb +12 -0
  93. data/spec/dummy/db/migrate/20141114170954_add_core_addresses.dm_core.rb +18 -0
  94. data/spec/dummy/db/migrate/20141114170955_papertrail_increase_column.dm_core.rb +9 -0
  95. data/spec/dummy/db/migrate/20141114170956_acts_as_taggable_on_migration.dm_core.rb +32 -0
  96. data/spec/dummy/db/migrate/20141114170957_add_missing_unique_indices.dm_core.rb +23 -0
  97. data/spec/dummy/db/migrate/20141114170958_add_taggings_counter_cache_to_tags.dm_core.rb +16 -0
  98. data/spec/dummy/db/migrate/20141114170959_create_custom_fields.dm_core.rb +40 -0
  99. data/spec/dummy/db/migrate/20141114170960_add_missing_taggable_index.dm_core.rb +11 -0
  100. data/spec/dummy/db/migrate/20141119112030_create_cms.dm_cms.rb +92 -0
  101. data/spec/dummy/db/migrate/20141119112031_add_account_to_cms.dm_cms.rb +11 -0
  102. data/spec/dummy/db/migrate/20141119112032_create_blog.dm_cms.rb +62 -0
  103. data/spec/dummy/db/migrate/20141119112033_add_notification_sent.dm_cms.rb +6 -0
  104. data/spec/dummy/db/migrate/20141119112034_add_blog_comment.dm_cms.rb +8 -0
  105. data/spec/dummy/db/migrate/20141119112035_add_blog_image.dm_cms.rb +6 -0
  106. data/spec/dummy/db/migrate/20141119112036_rename_snippet_slug.dm_cms.rb +14 -0
  107. data/spec/dummy/db/migrate/20141119112037_add_requires_subscription_blog.dm_cms.rb +8 -0
  108. data/spec/dummy/db/migrate/20141119112038_add_pages_ranked_model.dm_cms.rb +23 -0
  109. data/spec/dummy/db/migrate/20141119112039_add_blog_owner.dm_cms.rb +7 -0
  110. data/spec/dummy/db/migrate/20141119112040_create_media_files.dm_cms.rb +30 -0
  111. data/spec/dummy/db/migrate/20141119112041_add_cmspage_summary.dm_cms.rb +7 -0
  112. data/spec/dummy/db/migrate/20141119112042_add_blog_image_email_header.dm_cms.rb +6 -0
  113. data/spec/dummy/db/migrate/20141119112043_add_header_image.dm_cms.rb +10 -0
  114. data/spec/dummy/db/migrate/20160128145239_add_favored_locale.dm_core.rb +17 -0
  115. data/spec/dummy/db/migrate/20160128145240_update_papertrail_v4.dm_core.rb +41 -0
  116. data/spec/dummy/db/schema.rb +593 -0
  117. data/spec/dummy/public/404.html +67 -0
  118. data/spec/dummy/public/422.html +67 -0
  119. data/spec/dummy/public/500.html +66 -0
  120. data/spec/dummy/public/favicon.ico +0 -0
  121. data/spec/factories/accounts.rb +9 -0
  122. data/spec/factories/user_profiles.rb +10 -0
  123. data/spec/factories/users.rb +19 -0
  124. data/spec/models/newsletter_spec.rb +9 -0
  125. data/spec/rails_helper.rb +70 -0
  126. data/spec/spec_helper.rb +85 -0
  127. data/spec/support/accounts.rb +17 -0
  128. data/spec/support/devise.rb +44 -0
  129. data/spec/support/fix_locale.rb +57 -0
  130. metadata +296 -0
@@ -0,0 +1,9 @@
1
+ # This migration comes from dm_core (originally 20130415095617)
2
+ class AddTypeToComments < ActiveRecord::Migration
3
+ def change
4
+ add_column :core_comments, :type, :string
5
+ add_column :core_comments, :ancestry, :string
6
+ add_column :core_comments, :ancestry_depth, :integer, :default => 0
7
+ rename_column :core_comments, :comment, :body
8
+ end
9
+ end
@@ -0,0 +1,28 @@
1
+ # This migration comes from dm_core (originally 20130429191051)
2
+ class AddCategory < ActiveRecord::Migration
3
+ def up
4
+ create_table "core_category_translations", :force => true do |t|
5
+ t.integer :core_category_id
6
+ t.string :locale
7
+ t.string :name
8
+ t.string :description
9
+ t.datetime :created_at
10
+ t.datetime :updated_at
11
+ end
12
+
13
+ add_index "core_category_translations", ["core_category_id"], :name => "index_category_translation"
14
+
15
+ create_table "core_categories", :force => true do |t|
16
+ t.string :type
17
+ t.integer :row_order
18
+ t.integer :account_id
19
+ t.datetime :created_on
20
+ t.datetime :updated_on
21
+ end
22
+ end
23
+
24
+ def down
25
+ drop_table :core_categories
26
+ drop_table :core_category_translations
27
+ end
28
+ end
@@ -0,0 +1,26 @@
1
+ # This migration comes from dm_core (originally 20130513112751)
2
+ class CreateEmailTable < ActiveRecord::Migration
3
+ def up
4
+ create_table :core_system_email_translations, :force => true do |t|
5
+ t.integer :core_system_email_id
6
+ t.string :locale
7
+ t.string :subject
8
+ t.text :body
9
+ t.datetime :created_at
10
+ t.datetime :updated_at
11
+ end
12
+
13
+ create_table :core_system_emails, :force => true do |t|
14
+ t.string :email_type
15
+ t.references :emailable, :polymorphic => true
16
+ t.datetime :created_at
17
+ t.datetime :updated_at
18
+ t.integer :account_id
19
+ end
20
+ end
21
+
22
+ def down
23
+ drop_table :core_system_emails
24
+ drop_table :core_system_email_translations
25
+ end
26
+ end
@@ -0,0 +1,46 @@
1
+ # This migration comes from dm_core (originally 20130516143539)
2
+ class AddUserProfile < ActiveRecord::Migration
3
+ def up
4
+ create_table :user_profiles, :force => true do |t|
5
+ t.integer :user_id
6
+ t.string :public_name, :limit => 50, :default => ""
7
+ t.string :first_name, :limit => 50, :default => ""
8
+ t.string :last_name, :limit => 50, :default => ""
9
+ t.string :address, :limit => 70, :default => ""
10
+ t.string :address2, :limit => 70, :default => ""
11
+ t.string :city, :limit => 30, :default => ""
12
+ t.string :state, :limit => 30, :default => ""
13
+ t.string :zipcode, :limit => 10, :default => ""
14
+ t.integer :country_id, :default => 0
15
+ t.string :phone, :limit => 20, :default => ""
16
+ t.string :cell, :limit => 20, :default => ""
17
+ t.string :fax, :limit => 20, :default => ""
18
+ t.string :workphone, :limit => 20, :default => ""
19
+ t.string :website, :limit => 50, :default => ""
20
+ t.string :gender, :limit => 1, :default => ""
21
+ t.integer :status, :default => 0
22
+ t.integer :lock_version, :default => 0
23
+ t.datetime :last_access_at
24
+ t.datetime :created_at
25
+ t.datetime :updated_at
26
+ t.integer :account_id
27
+ end
28
+
29
+ User.all.find_each do |user|
30
+ Account.current = Account.find(user.account_id)
31
+ p = user.create_user_profile
32
+ p.update_attributes(first_name: user.attributes['first_name'], last_name: user.attributes['last_name'],
33
+ country_id: user.attributes['country_id'],
34
+ public_name: "#{user.attributes['first_name']}")
35
+ p.update_attribute(:last_access_at, user.attributes['last_access_at'])
36
+ end
37
+ remove_column :users, :first_name
38
+ remove_column :users, :last_name
39
+ remove_column :users, :country_id
40
+ remove_column :users, :last_access_at
41
+ end
42
+
43
+ def down
44
+ drop_table :user_profiles
45
+ end
46
+ end
@@ -0,0 +1,14 @@
1
+ # This migration comes from dm_core (originally 20130518155712)
2
+ class AddProfileEmail < ActiveRecord::Migration
3
+ def up
4
+ add_column :user_profiles, :email, :string
5
+ User.all.find_each do |user|
6
+ Account.current = Account.find(user.account_id)
7
+ user.user_profile.update_attribute(:email, user.attributes['email'])
8
+ end
9
+ end
10
+
11
+ def down
12
+ remove_column :user_profiles, :email
13
+ end
14
+ end
@@ -0,0 +1,37 @@
1
+ # This migration comes from dm_core (originally 20130620145610)
2
+ class CreatePaymentHistory < ActiveRecord::Migration
3
+ def up
4
+ create_table :core_payment_histories, :force => true do |t|
5
+ t.integer :owner_id
6
+ t.string :owner_type, :limit => 30
7
+ t.integer :anchor_id # unique number tying paid item to our item
8
+ t.string :order_ref # order number
9
+ t.string :item_ref # specfic item number
10
+ t.string :item_name # item's name
11
+ t.integer :quantity # number of items
12
+ t.string :cost # cost of item, as a string
13
+ t.string :discount # any coupon/dicsount
14
+ t.integer :total_cents # total amount in cents
15
+ t.string :total_currency, :limit => 3 # currency 3 char code
16
+ t.string :payment_method # how payment was made: cash, credit card, etc
17
+ t.datetime :payment_date # date of payment
18
+ t.string :bill_to_name # who actually paid / was billed to
19
+ t.text :item_details # any specific item details sent by payment processor
20
+ t.text :order_details # any specific order details sent by payment processor
21
+ t.string :current_stage # current stage of payment
22
+ t.integer :user_profile_id # user_profile if payment was enetered manually
23
+ t.datetime :created_on
24
+ t.integer :account_id
25
+ end
26
+
27
+ add_index "core_payment_histories", ["anchor_id"], :name => "index_payment_histories_on_anchor_id"
28
+ add_index "core_payment_histories", ["item_ref"], :name => "index_payment_histories_on_item_ref"
29
+ add_index "core_payment_histories", ["order_ref"], :name => "index_payment_histories_on_order_ref"
30
+ add_index "core_payment_histories", ["owner_id"], :name => "index_payment_histories_on_owner_id"
31
+ add_index "core_payment_histories", ["owner_type"], :name => "index_payment_histories_on_owner_type"
32
+ end
33
+
34
+ def down
35
+ drop_table :core_payment_histories
36
+ end
37
+ end
@@ -0,0 +1,10 @@
1
+ # This migration comes from dm_core (originally 20130625091108)
2
+ class ChangeAnchorField < ActiveRecord::Migration
3
+ def up
4
+ change_column :core_payment_histories, :anchor_id, :string, :limit => 20
5
+ end
6
+
7
+ def down
8
+ change_column :core_payment_histories, :anchor_id, :integer
9
+ end
10
+ end
@@ -0,0 +1,27 @@
1
+ # This migration comes from dm_core (originally 20130628112848)
2
+ class CreateUserSiteProfile < ActiveRecord::Migration
3
+ def up
4
+ create_table :user_site_profiles, :force => true do |t|
5
+ t.integer :user_id
6
+ t.datetime :last_access_at
7
+ t.datetime :created_at
8
+ t.datetime :updated_at
9
+ t.integer :account_id
10
+ end
11
+
12
+ User.all.find_each do |user|
13
+ Account.current = Account.find(user.account_id)
14
+ p = user.user_site_profiles.create
15
+ p.update_attribute(:account_id, user.attributes['account_id'])
16
+ p.update_attribute(:last_access_at, user.user_profile.attributes['last_access_at'])
17
+ p.update_attribute(:created_at, user.attributes['created_at'])
18
+ p.update_attribute(:updated_at, user.attributes['updated_at'])
19
+ end
20
+ remove_column :user_profiles, :last_access_at
21
+ end
22
+
23
+ def down
24
+ drop_table :user_site_profiles
25
+ add_column :user_profiles, :last_access_at, :datetime
26
+ end
27
+ end
@@ -0,0 +1,12 @@
1
+ # This migration comes from dm_core (originally 20130708150236)
2
+ class AddAvatar < ActiveRecord::Migration
3
+ def change
4
+ add_column :user_profiles, :public_avatar, :string
5
+ add_column :user_profiles, :public_avatar_file_size, :integer
6
+ add_column :user_profiles, :public_avatar_content_type, :string
7
+ add_column :user_profiles, :private_avatar, :string
8
+ add_column :user_profiles, :private_avatar_file_size, :integer
9
+ add_column :user_profiles, :private_avatar_content_type, :string
10
+ add_column :user_profiles, :use_private_avatar_for_public, :boolean, :default => false
11
+ end
12
+ end
@@ -0,0 +1,8 @@
1
+ # This migration comes from dm_core (originally 20130914132041)
2
+ class AddNotifyToPaymentHistory < ActiveRecord::Migration
3
+ def change
4
+ add_column :core_payment_histories, :notify_data, :text
5
+ add_column :core_payment_histories, :transaction_id, :string
6
+ rename_column :core_payment_histories, :current_stage, :status
7
+ end
8
+ end
@@ -0,0 +1,28 @@
1
+ # This migration comes from dm_core (originally 20140105133446)
2
+ class ActsAsVotableMigration < ActiveRecord::Migration
3
+ def self.up
4
+ create_table :votes do |t|
5
+
6
+ t.references :votable, :polymorphic => true
7
+ t.references :voter, :polymorphic => true
8
+
9
+ t.boolean :vote_flag
10
+ t.string :vote_scope
11
+ t.integer :vote_weight
12
+
13
+ t.timestamps null: true
14
+ end
15
+
16
+ if ActiveRecord::VERSION::MAJOR < 4
17
+ add_index :votes, [:votable_id, :votable_type]
18
+ add_index :votes, [:voter_id, :voter_type]
19
+ end
20
+
21
+ add_index :votes, [:voter_id, :voter_type, :vote_scope]
22
+ add_index :votes, [:votable_id, :votable_type, :vote_scope]
23
+ end
24
+
25
+ def self.down
26
+ drop_table :votes
27
+ end
28
+ end
@@ -0,0 +1,19 @@
1
+ # This migration comes from dm_core (originally 20140107112418)
2
+ class UserSiteProfile < ActiveRecord::Base
3
+ end
4
+
5
+ class AddUserSiteProfileUuid < ActiveRecord::Migration
6
+ def up
7
+ add_column :user_site_profiles, :uuid, :string, :limit => 40
8
+ add_index :user_site_profiles, :uuid
9
+
10
+ #--- Create uuid for existing records
11
+ UserSiteProfile.all.each do |profile|
12
+ profile.update_attribute(:uuid, SecureRandom.uuid)
13
+ end
14
+ end
15
+
16
+ def down
17
+ remove_column :user_site_profiles, :uuid
18
+ end
19
+ end
@@ -0,0 +1,7 @@
1
+ # This migration comes from dm_core (originally 20140129110547)
2
+ class AddInvoiceId < ActiveRecord::Migration
3
+ def change
4
+ # used to track an atomically increasing invoice id for an account (used in payments)
5
+ add_column :core_accounts, :invoice_id_counter, :integer
6
+ end
7
+ end
@@ -0,0 +1,18 @@
1
+ # This migration comes from dm_core (originally 20140201092656)
2
+ class ActsAsFollowerMigration < ActiveRecord::Migration
3
+ def self.up
4
+ create_table :follows, :force => true do |t|
5
+ t.references :followable, :polymorphic => true, :null => false
6
+ t.references :follower, :polymorphic => true, :null => false
7
+ t.boolean :blocked, :default => false, :null => false
8
+ t.timestamps null: true
9
+ end
10
+
11
+ add_index :follows, ["follower_id", "follower_type"], :name => "fk_follows"
12
+ add_index :follows, ["followable_id", "followable_type"], :name => "fk_followables"
13
+ end
14
+
15
+ def self.down
16
+ drop_table :follows
17
+ end
18
+ end
@@ -0,0 +1,12 @@
1
+ # This migration comes from dm_core (originally 20140203131320)
2
+ class RenameInvoiceId < ActiveRecord::Migration
3
+ def up
4
+ remove_column :core_accounts, :invoice_id_counter
5
+ add_column :core_accounts, :next_invoice_num, :integer, :default => 1000
6
+ end
7
+
8
+ def down
9
+ remove_column :core_accounts, :next_invoice_num
10
+ add_column :core_accounts, :invoice_id_counter, :integer
11
+ end
12
+ end
@@ -0,0 +1,18 @@
1
+ # This migration comes from dm_core (originally 20140210195143)
2
+ class AddCoreAddresses < ActiveRecord::Migration
3
+ def change
4
+ create_table :core_addresses do |t|
5
+ t.string :line1
6
+ t.string :line2
7
+ t.string :city
8
+ t.string :state
9
+ t.string :zip
10
+ t.string :country_code, limit: 2
11
+ t.integer :addressable_id
12
+ t.string :addressable_type
13
+ t.timestamps null: true
14
+ end
15
+
16
+ add_index :core_addresses, [:addressable_type, :addressable_id], :unique => true
17
+ end
18
+ end
@@ -0,0 +1,9 @@
1
+ # This migration comes from dm_core (originally 20140411190454)
2
+ class PapertrailIncreaseColumn < ActiveRecord::Migration
3
+ def up
4
+ change_column :versions, :object_changes, :mediumtext
5
+ end
6
+ def down
7
+ change_column :versions, :object_changes, :text
8
+ end
9
+ end
@@ -0,0 +1,32 @@
1
+ # This migration comes from dm_core (originally 20140501160009)
2
+ # This migration comes from acts_as_taggable_on_engine (originally 1)
3
+ class ActsAsTaggableOnMigration < ActiveRecord::Migration
4
+ def self.up
5
+ create_table :tags do |t|
6
+ t.string :name
7
+ end
8
+
9
+ create_table :taggings do |t|
10
+ t.references :tag
11
+
12
+ # You should make sure that the column created is
13
+ # long enough to store the required class names.
14
+ t.references :taggable, :polymorphic => true
15
+ t.references :tagger, :polymorphic => true
16
+
17
+ # Limit is created to prevent MySQL error on index
18
+ # length for MyISAM table type: http://bit.ly/vgW2Ql
19
+ t.string :context, :limit => 128
20
+
21
+ t.datetime :created_at
22
+ end
23
+
24
+ add_index :taggings, :tag_id
25
+ add_index :taggings, [:taggable_id, :taggable_type, :context]
26
+ end
27
+
28
+ def self.down
29
+ drop_table :taggings
30
+ drop_table :tags
31
+ end
32
+ end
@@ -0,0 +1,23 @@
1
+ # This migration comes from dm_core (originally 20140501160010)
2
+ # This migration comes from acts_as_taggable_on_engine (originally 2)
3
+ class AddMissingUniqueIndices < ActiveRecord::Migration
4
+
5
+ def self.up
6
+ add_index :tags, :name, unique: true
7
+
8
+ remove_index :taggings, :tag_id
9
+ remove_index :taggings, [:taggable_id, :taggable_type, :context]
10
+ add_index :taggings,
11
+ [:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, :tagger_type],
12
+ unique: true, name: 'taggings_idx'
13
+ end
14
+
15
+ def self.down
16
+ remove_index :tags, :name
17
+
18
+ remove_index :taggings, name: 'taggings_idx'
19
+ add_index :taggings, :tag_id
20
+ add_index :taggings, [:taggable_id, :taggable_type, :context]
21
+ end
22
+
23
+ end
@@ -0,0 +1,16 @@
1
+ # This migration comes from dm_core (originally 20140501160011)
2
+ # This migration comes from acts_as_taggable_on_engine (originally 3)
3
+ class AddTaggingsCounterCacheToTags < ActiveRecord::Migration
4
+ def self.up
5
+ add_column :tags, :taggings_count, :integer, :default => 0
6
+
7
+ ActsAsTaggableOn::Tag.reset_column_information
8
+ ActsAsTaggableOn::Tag.find_each do |tag|
9
+ ActsAsTaggableOn::Tag.reset_counters(tag.id, :taggings)
10
+ end
11
+ end
12
+
13
+ def self.down
14
+ remove_column :tags, :taggings_count
15
+ end
16
+ end
@@ -0,0 +1,40 @@
1
+ # This migration comes from dm_core (originally 20140529164730)
2
+ class CreateCustomFields < ActiveRecord::Migration
3
+ def change
4
+ create_table :core_custom_field_defs do |t|
5
+ t.references :owner, polymorphic: true
6
+ t.string :name
7
+ t.string :field_type
8
+ t.integer :row_order
9
+ t.boolean :required, default: false
10
+ t.string :properties, limit: 2048
11
+ t.timestamps null: true
12
+ t.integer :account_id
13
+ end
14
+
15
+ add_index :core_custom_field_defs, :account_id
16
+ add_index :core_custom_field_defs, [:owner_id, :owner_type]
17
+
18
+ create_table :core_custom_field_def_translations, force: true do |t|
19
+ t.integer :core_custom_field_def_id
20
+ t.string :locale
21
+ t.string :label
22
+ t.text :description
23
+ t.datetime :created_at
24
+ t.datetime :updated_at
25
+ end
26
+
27
+ add_index :core_custom_field_def_translations, [:core_custom_field_def_id], name: 'core_custom_field_def_translations_index'
28
+
29
+ create_table :core_custom_fields do |t|
30
+ t.references :owner, polymorphic: true
31
+ t.integer :custom_field_def_id
32
+ t.string :field_data, limit: 4096
33
+ t.timestamps null: true
34
+ t.integer :account_id
35
+ end
36
+
37
+ add_index :core_custom_fields, :account_id
38
+ add_index :core_custom_fields, [:owner_id, :owner_type]
39
+ end
40
+ end