storytime 1.1.1 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/storytime/application_controller.rb +3 -3
  3. data/app/models/storytime/autosave.rb +1 -1
  4. data/app/models/storytime/comment.rb +1 -1
  5. data/app/models/storytime/media.rb +1 -1
  6. data/app/models/storytime/post.rb +1 -1
  7. data/app/models/storytime/version.rb +1 -1
  8. data/app/views/storytime/application/storytime/_header.html.erb +1 -1
  9. data/app/views/storytime/dashboard/_navigation.html.erb +1 -1
  10. data/lib/generators/templates/storytime.rb +10 -1
  11. data/lib/storytime.rb +18 -2
  12. data/lib/storytime/version.rb +1 -1
  13. data/spec/dummy/db/development.sqlite3 +0 -0
  14. data/spec/dummy/db/test.sqlite3 +0 -0
  15. metadata +2 -40
  16. data/spec/dummy/db/migrate/20150130213631_create_storytime_posts.storytime.rb +0 -18
  17. data/spec/dummy/db/migrate/20150130213632_create_friendly_id_slugs.storytime.rb +0 -16
  18. data/spec/dummy/db/migrate/20150130213633_create_storytime_media.storytime.rb +0 -11
  19. data/spec/dummy/db/migrate/20150130213634_create_storytime_sites.storytime.rb +0 -14
  20. data/spec/dummy/db/migrate/20150130213635_create_storytime_tags.storytime.rb +0 -10
  21. data/spec/dummy/db/migrate/20150130213636_create_storytime_taggings.storytime.rb +0 -11
  22. data/spec/dummy/db/migrate/20150130213637_create_storytime_versions.storytime.rb +0 -13
  23. data/spec/dummy/db/migrate/20150130213638_create_storytime_roles.storytime.rb +0 -10
  24. data/spec/dummy/db/migrate/20150130213639_add_storytime_role_id_to_users.storytime.rb +0 -7
  25. data/spec/dummy/db/migrate/20150130213640_create_storytime_permissions.storytime.rb +0 -11
  26. data/spec/dummy/db/migrate/20150130213641_create_storytime_actions.storytime.rb +0 -11
  27. data/spec/dummy/db/migrate/20150130213642_create_storytime_comments.storytime.rb +0 -12
  28. data/spec/dummy/db/migrate/20150130213643_add_storytime_name_to_users.storytime.rb +0 -6
  29. data/spec/dummy/db/migrate/20150130213644_create_storytime_autosaves.storytime.rb +0 -13
  30. data/spec/dummy/db/migrate/20150130213645_add_secondary_media_id_to_storytime_post.storytime.rb +0 -6
  31. data/spec/dummy/db/migrate/20150130213646_create_storytime_snippets.storytime.rb +0 -22
  32. data/spec/dummy/db/migrate/20150130213647_create_storytime_subscriptions.storytime.rb +0 -15
  33. data/spec/dummy/db/migrate/20150130213648_add_title_and_content_index_to_storytime_post.storytime.rb +0 -57
  34. data/spec/dummy/db/migrate/20150130213649_add_site_id_to_storytime_subscription.storytime.rb +0 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 06f4a653cab5a07931cdc7c80d0892bd5a7daa12
4
- data.tar.gz: 3fb261085ce26f70bf249ce1724a3005afa3c6f7
3
+ metadata.gz: f5763a623b7cbc3a4338fb7ad83ddc56a5dbb8e3
4
+ data.tar.gz: dc51e884bd9e91cf0cc466edbdc5a54ce1a74abc
5
5
  SHA512:
6
- metadata.gz: 3d35eeeb18f0d289a16f3a7b312d2e76f17220dfd57b0c6077cea8de1012dc9a0227cdac33c8a05a444e5d819cd5b03e70b8e79138d8e14490ca959314cfe4e0
7
- data.tar.gz: 5b5621d9c72c07e3ede66912eefc1c06a629ffca917075915e153bdf0e4a7f7aee85d14c262f8670654c520aea03fec3c435544f79384e06c724c540d3eb47a7
6
+ metadata.gz: 0614230034de10544be38ed69510228d33c0655ed48b02bcaf9f975626aac957204ecbf5541848c6ad3fb79b7175314dfc0656b2b0d26df2e4c121e88ed1f132
7
+ data.tar.gz: ce87e3b715e67c59f8254143f4fff0a7f5baecfc026cee4f895bc409c01dcad268c8d2b66b855eeb8149dd572d8c6d8172afd54285d926e9110872c708908688
@@ -30,15 +30,15 @@ class Storytime::ApplicationController < ApplicationController
30
30
 
31
31
  if Storytime.user_class_symbol != :user
32
32
  def authenticate_user!
33
- send("authenticate_#{Storytime.user_class.to_s.downcase}!".to_sym)
33
+ send("authenticate_#{Storytime.user_class_underscore_all}!".to_sym)
34
34
  end
35
35
 
36
36
  def current_user
37
- send("current_#{Storytime.user_class.to_s.downcase}".to_sym)
37
+ send("current_#{Storytime.user_class_underscore_all}".to_sym)
38
38
  end
39
39
 
40
40
  def user_signed_in?
41
- send("#{Storytime.user_class.to_s.downcase}_signed_in?".to_sym)
41
+ send("#{Storytime.user_class_underscore_all}_signed_in?".to_sym)
42
42
  end
43
43
  end
44
44
 
@@ -1,6 +1,6 @@
1
1
  module Storytime
2
2
  class Autosave < ActiveRecord::Base
3
- belongs_to :user, class_name: Storytime.user_class.to_s
3
+ belongs_to :user, class_name: Storytime.user_class
4
4
  belongs_to :autosavable, polymorphic: true
5
5
 
6
6
  attr_accessor :draft_content
@@ -1,6 +1,6 @@
1
1
  module Storytime
2
2
  class Comment < ActiveRecord::Base
3
- belongs_to :user, class_name: Storytime.user_class.to_s
3
+ belongs_to :user, class_name: Storytime.user_class
4
4
  belongs_to :post
5
5
 
6
6
  validates :user, presence: true
@@ -1,6 +1,6 @@
1
1
  module Storytime
2
2
  class Media < ActiveRecord::Base
3
- belongs_to :user, class_name: Storytime.user_class.to_s
3
+ belongs_to :user, class_name: Storytime.user_class
4
4
  has_many :posts # posts where this is the featured media
5
5
 
6
6
  mount_uploader :file, MediaUploader
@@ -6,7 +6,7 @@ module Storytime
6
6
  extend FriendlyId
7
7
  friendly_id :slug_candidates, use: [:history]
8
8
 
9
- belongs_to :user, class_name: Storytime.user_class.to_s
9
+ belongs_to :user, class_name: Storytime.user_class
10
10
  belongs_to :featured_media, class_name: "Media"
11
11
  belongs_to :secondary_media, class_name: "Media"
12
12
 
@@ -1,6 +1,6 @@
1
1
  module Storytime
2
2
  class Version < ActiveRecord::Base
3
- belongs_to :user, class_name: Storytime.user_class.to_s
3
+ belongs_to :user, class_name: Storytime.user_class
4
4
  belongs_to :versionable, polymorphic: true
5
5
  end
6
6
  end
@@ -22,7 +22,7 @@
22
22
  <%= link_to "#{t 'layout.subscribe_to', site_name: @site.title}", "#", data: {target: "#addSubscriptionModal", toggle: "modal"} %>
23
23
  </li>
24
24
  <% unless user_signed_in? %>
25
- <li><%= link_to "Sign In", main_app.new_user_session_path %></li>
25
+ <li><%= link_to "Sign In", Storytime.login_path %></li>
26
26
  <% end %>
27
27
  </ul>
28
28
  </div>
@@ -45,7 +45,7 @@
45
45
  </a>
46
46
  <ul class="dropdown-menu">
47
47
  <li><%= link_to "My Account", storytime.edit_dashboard_user_path(current_user) %></li>
48
- <li><%= link_to "Sign Out", main_app.send("destroy_#{Storytime.user_class_underscore}_session_path"), method: :delete %></li>
48
+ <li><%= link_to "Sign Out", Storytime.logout_path, method: Storytime.logout_method %></li>
49
49
  </ul>
50
50
  </li>
51
51
  </ul>
@@ -15,6 +15,15 @@ Storytime.configure do |config|
15
15
  # Storytime's mount point within the host app.
16
16
  # config.home_page_path = "/"
17
17
 
18
+ # Path used to sign users in.
19
+ # config.login_path = '/users/sign_in'
20
+
21
+ # Path used to log users out.
22
+ # config.logout_path = '/users/sign_out'
23
+
24
+ # Method used for Storytime user logout path.
25
+ # config.logout_method = :delete
26
+
18
27
  # Add custom post types to use within Storytime.
19
28
  # Make sure that the custom post types inherit the
20
29
  # from the Storytime::Post class.
@@ -41,7 +50,7 @@ Storytime.configure do |config|
41
50
  # Post subclasses. Options for the search adapter include:
42
51
  # Storytime::PostgresSearchAdapter, Storytime::MysqlSearchAdapter,
43
52
  # Storytime::MysqlFulltextSearchAdapter, Storytime::Sqlite3SearchAdapter
44
- # config.search_adapter = Storytime::PostgresSearchAdapter
53
+ # config.search_adapter = ''
45
54
 
46
55
  # File upload options.
47
56
  config.enable_file_upload = true
data/lib/storytime.rb CHANGED
@@ -19,6 +19,18 @@ module Storytime
19
19
  mattr_accessor :home_page_path
20
20
  @@home_page_path = "/"
21
21
 
22
+ # Path used to sign users in.
23
+ mattr_accessor :login_path
24
+ @@login_path = '/users/sign_in'
25
+
26
+ # Path used to log users out.
27
+ mattr_accessor :logout_path
28
+ @@logout_path = '/users/sign_out'
29
+
30
+ # Method used for Storytime user logout path.
31
+ mattr_accessor :logout_method
32
+ @@logout_method = :delete
33
+
22
34
  # Enable file uploads through Carrierwave.
23
35
  mattr_accessor :enable_file_upload
24
36
  @@enable_file_upload = true
@@ -55,7 +67,7 @@ module Storytime
55
67
  # Storytime::PostgresSearchAdapter, Storytime::MysqlSearchAdapter,
56
68
  # Storytime::MysqlFulltextSearchAdapter, Storytime::Sqlite3SearchAdapter
57
69
  mattr_accessor :search_adapter
58
- @@search_adapter = Storytime::PostgresSearchAdapter
70
+ @@search_adapter = ''
59
71
 
60
72
  class << self
61
73
  attr_accessor :layout, :media_storage, :s3_bucket, :post_types
@@ -71,7 +83,11 @@ module Storytime
71
83
  end
72
84
 
73
85
  def user_class_underscore
74
- @@user_class.to_s.underscore
86
+ @@user_class.underscore
87
+ end
88
+
89
+ def user_class_underscore_all
90
+ @@user_class.underscore.gsub('/', '_')
75
91
  end
76
92
 
77
93
  def user_class_symbol
@@ -1,3 +1,3 @@
1
1
  module Storytime
2
- VERSION = "1.1.1"
2
+ VERSION = "1.2.0"
3
3
  end
Binary file
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: storytime
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Roesch, David Van Der Beek, Brandon Robins
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-30 00:00:00.000000000 Z
11
+ date: 2015-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -679,25 +679,6 @@ files:
679
679
  - spec/dummy/config/secrets.yml
680
680
  - spec/dummy/db/development.sqlite3
681
681
  - spec/dummy/db/migrate/20140530185250_devise_create_users.rb
682
- - spec/dummy/db/migrate/20150130213631_create_storytime_posts.storytime.rb
683
- - spec/dummy/db/migrate/20150130213632_create_friendly_id_slugs.storytime.rb
684
- - spec/dummy/db/migrate/20150130213633_create_storytime_media.storytime.rb
685
- - spec/dummy/db/migrate/20150130213634_create_storytime_sites.storytime.rb
686
- - spec/dummy/db/migrate/20150130213635_create_storytime_tags.storytime.rb
687
- - spec/dummy/db/migrate/20150130213636_create_storytime_taggings.storytime.rb
688
- - spec/dummy/db/migrate/20150130213637_create_storytime_versions.storytime.rb
689
- - spec/dummy/db/migrate/20150130213638_create_storytime_roles.storytime.rb
690
- - spec/dummy/db/migrate/20150130213639_add_storytime_role_id_to_users.storytime.rb
691
- - spec/dummy/db/migrate/20150130213640_create_storytime_permissions.storytime.rb
692
- - spec/dummy/db/migrate/20150130213641_create_storytime_actions.storytime.rb
693
- - spec/dummy/db/migrate/20150130213642_create_storytime_comments.storytime.rb
694
- - spec/dummy/db/migrate/20150130213643_add_storytime_name_to_users.storytime.rb
695
- - spec/dummy/db/migrate/20150130213644_create_storytime_autosaves.storytime.rb
696
- - spec/dummy/db/migrate/20150130213645_add_secondary_media_id_to_storytime_post.storytime.rb
697
- - spec/dummy/db/migrate/20150130213646_create_storytime_snippets.storytime.rb
698
- - spec/dummy/db/migrate/20150130213647_create_storytime_subscriptions.storytime.rb
699
- - spec/dummy/db/migrate/20150130213648_add_title_and_content_index_to_storytime_post.storytime.rb
700
- - spec/dummy/db/migrate/20150130213649_add_site_id_to_storytime_subscription.storytime.rb
701
682
  - spec/dummy/db/schema.rb
702
683
  - spec/dummy/db/test.sqlite3
703
684
  - spec/dummy/public/404.html
@@ -819,25 +800,6 @@ test_files:
819
800
  - spec/dummy/config.ru
820
801
  - spec/dummy/db/development.sqlite3
821
802
  - spec/dummy/db/migrate/20140530185250_devise_create_users.rb
822
- - spec/dummy/db/migrate/20150130213631_create_storytime_posts.storytime.rb
823
- - spec/dummy/db/migrate/20150130213632_create_friendly_id_slugs.storytime.rb
824
- - spec/dummy/db/migrate/20150130213633_create_storytime_media.storytime.rb
825
- - spec/dummy/db/migrate/20150130213634_create_storytime_sites.storytime.rb
826
- - spec/dummy/db/migrate/20150130213635_create_storytime_tags.storytime.rb
827
- - spec/dummy/db/migrate/20150130213636_create_storytime_taggings.storytime.rb
828
- - spec/dummy/db/migrate/20150130213637_create_storytime_versions.storytime.rb
829
- - spec/dummy/db/migrate/20150130213638_create_storytime_roles.storytime.rb
830
- - spec/dummy/db/migrate/20150130213639_add_storytime_role_id_to_users.storytime.rb
831
- - spec/dummy/db/migrate/20150130213640_create_storytime_permissions.storytime.rb
832
- - spec/dummy/db/migrate/20150130213641_create_storytime_actions.storytime.rb
833
- - spec/dummy/db/migrate/20150130213642_create_storytime_comments.storytime.rb
834
- - spec/dummy/db/migrate/20150130213643_add_storytime_name_to_users.storytime.rb
835
- - spec/dummy/db/migrate/20150130213644_create_storytime_autosaves.storytime.rb
836
- - spec/dummy/db/migrate/20150130213645_add_secondary_media_id_to_storytime_post.storytime.rb
837
- - spec/dummy/db/migrate/20150130213646_create_storytime_snippets.storytime.rb
838
- - spec/dummy/db/migrate/20150130213647_create_storytime_subscriptions.storytime.rb
839
- - spec/dummy/db/migrate/20150130213648_add_title_and_content_index_to_storytime_post.storytime.rb
840
- - spec/dummy/db/migrate/20150130213649_add_site_id_to_storytime_subscription.storytime.rb
841
803
  - spec/dummy/db/schema.rb
842
804
  - spec/dummy/db/test.sqlite3
843
805
  - spec/dummy/public/404.html
@@ -1,18 +0,0 @@
1
- # This migration comes from storytime (originally 20140501174341)
2
- class CreateStorytimePosts < ActiveRecord::Migration
3
- def change
4
- create_table :storytime_posts do |t|
5
- t.references :user, index: true
6
- t.string :type
7
- t.string :title
8
- t.string :slug, index: true
9
- t.text :content
10
- t.text :excerpt
11
- t.datetime :published_at
12
- t.references :featured_media
13
- t.boolean :featured, default: false
14
-
15
- t.timestamps
16
- end
17
- end
18
- end
@@ -1,16 +0,0 @@
1
- # This migration comes from storytime (originally 20140509191309)
2
- class CreateFriendlyIdSlugs < ActiveRecord::Migration
3
- def change
4
- create_table :friendly_id_slugs do |t|
5
- t.string :slug, :null => false
6
- t.integer :sluggable_id, :null => false
7
- t.string :sluggable_type, :limit => 50
8
- t.string :scope
9
- t.datetime :created_at
10
- end
11
- add_index :friendly_id_slugs, :sluggable_id
12
- add_index :friendly_id_slugs, [:slug, :sluggable_type]
13
- add_index :friendly_id_slugs, [:slug, :sluggable_type, :scope], :unique => true
14
- add_index :friendly_id_slugs, :sluggable_type
15
- end
16
- end
@@ -1,11 +0,0 @@
1
- # This migration comes from storytime (originally 20140511200849)
2
- class CreateStorytimeMedia < ActiveRecord::Migration
3
- def change
4
- create_table :storytime_media do |t|
5
- t.string :file
6
- t.references :user, index: true
7
-
8
- t.timestamps
9
- end
10
- end
11
- end
@@ -1,14 +0,0 @@
1
- # This migration comes from storytime (originally 20140513161233)
2
- class CreateStorytimeSites < ActiveRecord::Migration
3
- def change
4
- create_table :storytime_sites do |t|
5
- t.string :title
6
- t.integer :post_slug_style, default: 0
7
- t.string :ga_tracking_id
8
- t.integer :root_page_content, default: 0
9
- t.references :root_post, index: true
10
-
11
- t.timestamps
12
- end
13
- end
14
- end
@@ -1,10 +0,0 @@
1
- # This migration comes from storytime (originally 20140514200234)
2
- class CreateStorytimeTags < ActiveRecord::Migration
3
- def change
4
- create_table :storytime_tags do |t|
5
- t.string :name
6
-
7
- t.timestamps
8
- end
9
- end
10
- end
@@ -1,11 +0,0 @@
1
- # This migration comes from storytime (originally 20140514200304)
2
- class CreateStorytimeTaggings < ActiveRecord::Migration
3
- def change
4
- create_table :storytime_taggings do |t|
5
- t.belongs_to :tag, index: true
6
- t.belongs_to :post, index: true
7
-
8
- t.timestamps
9
- end
10
- end
11
- end
@@ -1,13 +0,0 @@
1
- # This migration comes from storytime (originally 20140516141252)
2
- class CreateStorytimeVersions < ActiveRecord::Migration
3
- def change
4
- create_table :storytime_versions do |t|
5
- t.text :content
6
- t.references :user, index: true
7
- t.references :versionable, polymorphic: true
8
-
9
- t.timestamps
10
- end
11
- add_index :storytime_versions, [:versionable_type, :versionable_id], name: "versionable_index"
12
- end
13
- end
@@ -1,10 +0,0 @@
1
- # This migration comes from storytime (originally 20140521190606)
2
- class CreateStorytimeRoles < ActiveRecord::Migration
3
- def change
4
- create_table :storytime_roles do |t|
5
- t.string :name, index: true
6
-
7
- t.timestamps
8
- end
9
- end
10
- end
@@ -1,7 +0,0 @@
1
- # This migration comes from storytime (originally 20140521191048)
2
- class AddStorytimeRoleIdToUsers < ActiveRecord::Migration
3
- def change
4
- add_column Storytime.user_class.table_name.to_sym, :storytime_role_id, :integer
5
- add_index Storytime.user_class.table_name.to_sym, :storytime_role_id
6
- end
7
- end
@@ -1,11 +0,0 @@
1
- # This migration comes from storytime (originally 20140521191728)
2
- class CreateStorytimePermissions < ActiveRecord::Migration
3
- def change
4
- create_table :storytime_permissions do |t|
5
- t.belongs_to :role, index: true
6
- t.belongs_to :action, index: true
7
-
8
- t.timestamps
9
- end
10
- end
11
- end
@@ -1,11 +0,0 @@
1
- # This migration comes from storytime (originally 20140521191744)
2
- class CreateStorytimeActions < ActiveRecord::Migration
3
- def change
4
- create_table :storytime_actions do |t|
5
- t.string :name
6
- t.string :guid, index: true
7
-
8
- t.timestamps
9
- end
10
- end
11
- end
@@ -1,12 +0,0 @@
1
- # This migration comes from storytime (originally 20140813014447)
2
- class CreateStorytimeComments < ActiveRecord::Migration
3
- def change
4
- create_table :storytime_comments do |t|
5
- t.text :content
6
- t.references :user, index: true
7
- t.references :post, index: true
8
-
9
- t.timestamps
10
- end
11
- end
12
- end
@@ -1,6 +0,0 @@
1
- # This migration comes from storytime (originally 20140813130534)
2
- class AddStorytimeNameToUsers < ActiveRecord::Migration
3
- def change
4
- add_column Storytime.user_class.table_name.to_sym, :storytime_name, :string
5
- end
6
- end
@@ -1,13 +0,0 @@
1
- # This migration comes from storytime (originally 20140916183056)
2
- class CreateStorytimeAutosaves < ActiveRecord::Migration
3
- def change
4
- create_table :storytime_autosaves do |t|
5
- t.text :content
6
- t.references :autosavable, polymorphic: true
7
-
8
- t.timestamps
9
- end
10
-
11
- add_index :storytime_autosaves, [:autosavable_type, :autosavable_id], name: "autosavable_index"
12
- end
13
- end
@@ -1,6 +0,0 @@
1
- # This migration comes from storytime (originally 20141020213343)
2
- class AddSecondaryMediaIdToStorytimePost < ActiveRecord::Migration
3
- def change
4
- add_reference :storytime_posts, :secondary_media
5
- end
6
- end
@@ -1,22 +0,0 @@
1
- # This migration comes from storytime (originally 20141021073356)
2
- class CreateStorytimeSnippets < ActiveRecord::Migration
3
- def up
4
- create_table :storytime_snippets do |t|
5
- t.string :name, index: true
6
- t.text :content
7
-
8
- t.timestamps
9
- end
10
-
11
- Storytime::Role.seed
12
- Storytime::Action.seed
13
-
14
- manage_snippets = Storytime::Action.find_by(guid: "5qg25i")
15
- Storytime::Permission.find_or_create_by(role: Storytime::Role.find_by(name: "editor"), action: manage_snippets)
16
- Storytime::Permission.find_or_create_by(role: Storytime::Role.find_by(name: "admin"), action: manage_snippets)
17
- end
18
-
19
- def down
20
- drop_table :storytime_snippets
21
- end
22
- end
@@ -1,15 +0,0 @@
1
- # This migration comes from storytime (originally 20141111164439)
2
- class CreateStorytimeSubscriptions < ActiveRecord::Migration
3
- def change
4
- create_table :storytime_subscriptions do |t|
5
- t.string :email
6
- t.boolean :subscribed, default: true
7
- t.string :token, index: true
8
-
9
- t.timestamps
10
- end
11
-
12
- Storytime::Action.seed
13
- Storytime::Permission.seed
14
- end
15
- end
@@ -1,57 +0,0 @@
1
- # This migration comes from storytime (originally 20150122200805)
2
- class AddTitleAndContentIndexToStorytimePost < ActiveRecord::Migration
3
- def up
4
- if Storytime.search_adapter == Storytime::PostgresSearchAdapter
5
- execute "CREATE INDEX posts_title_contentx ON storytime_posts USING gin(to_tsvector('english', coalesce(title, '') || ' ' || coalesce(content, '')));"
6
- elsif Storytime.search_adapter == Storytime::MysqlSearchAdapter
7
- type = get_table_type
8
- version = get_mysql_version
9
-
10
- if (type == "MyISAM") || (type == "InnoDB" && Gem::Version.new(version) >= Gem::Version.new("5.6.4"))
11
- add_index :storytime_posts, [:title, :content], type: :fulltext, :length => 50
12
- elsif type == "InnoDB"
13
- add_index :storytime_posts, [:title, :content], :length => 50
14
- end
15
- elsif Storytime.search_adapter == Storytime::MysqlFulltextSearchAdapter
16
- add_index :storytime_posts, [:title, :content], type: :fulltext, :length => 50
17
- end
18
- end
19
-
20
- def down
21
- if Storytime.search_adapter == Storytime::PostgresSearchAdapter
22
- execute "REMOVE INDEX posts_title_contentx ON storytime_posts"
23
- elsif Storytime.search_adapter == Storytime::MysqlSearchAdapter
24
- type = get_table_type
25
- version = get_mysql_version
26
-
27
- if (type == "MyISAM") || (type == "InnoDB" && Gem::Version.new(version) >= Gem::Version.new("5.6.4"))
28
- remove_index :storytime_posts, [:title, :content], type: :fulltext
29
- elsif type == "InnoDB"
30
- remove_index :storytime_posts, [:title, :content]
31
- end
32
- elsif Storytime.search_adapter == Storytime::MysqlFulltextSearchAdapter
33
- remove_index :storytime_posts, [:title, :content], type: :fulltext
34
- end
35
- end
36
-
37
- def get_table_type
38
- config = Rails.configuration.database_configuration
39
- database_name = config[Rails.env]["database"]
40
-
41
- sql = "SELECT TABLE_NAME, ENGINE FROM information_schema.TABLES where TABLE_SCHEMA = '#{database_name}'"
42
- query = ActiveRecord::Base.connection.execute(sql)
43
-
44
- query.entries.each do |k,v|
45
- if k == "storytime_posts"
46
- return v
47
- end
48
- end
49
- end
50
-
51
- def get_mysql_version
52
- sql = "SELECT VERSION()"
53
- query = ActiveRecord::Base.connection.execute(sql)
54
-
55
- query.entries[0][0]
56
- end
57
- end
@@ -1,6 +0,0 @@
1
- # This migration comes from storytime (originally 20150129215308)
2
- class AddSiteIdToStorytimeSubscription < ActiveRecord::Migration
3
- def change
4
- add_column :storytime_subscriptions, :site_id, :integer
5
- end
6
- end