enju_purchase_request 0.1.1 → 0.2.0.beta.2

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 (84) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +3 -3
  3. data/app/controllers/concerns/enju_purchase_request/controller.rb +19 -0
  4. data/app/controllers/order_lists_controller.rb +13 -3
  5. data/app/controllers/orders_controller.rb +13 -3
  6. data/app/controllers/purchase_requests_controller.rb +15 -10
  7. data/app/models/concerns/enju_purchase_request/enju_user.rb +10 -0
  8. data/app/models/order.rb +3 -4
  9. data/app/models/order_list.rb +2 -2
  10. data/app/models/order_list_transition.rb +5 -4
  11. data/app/models/purchase_request.rb +7 -8
  12. data/app/policies/bookstore_policy.rb +23 -0
  13. data/app/policies/order_list_policy.rb +21 -0
  14. data/app/policies/order_policy.rb +21 -0
  15. data/app/policies/purchase_request_policy.rb +25 -0
  16. data/app/views/orders/index.html.erb +5 -3
  17. data/app/views/purchase_requests/_index.html.erb +7 -7
  18. data/app/views/purchase_requests/_index_order_list.html.erb +6 -4
  19. data/app/views/purchase_requests/show.html.erb +1 -1
  20. data/db/migrate/20160703190738_add_most_recent_to_order_list_transitions.rb +9 -0
  21. data/lib/enju_purchase_request/version.rb +1 -1
  22. data/lib/enju_purchase_request.rb +0 -25
  23. data/lib/tasks/enju_purchase_request_tasks.rake +8 -0
  24. data/spec/controllers/order_lists_controller_spec.rb +13 -11
  25. data/spec/controllers/orders_controller_spec.rb +9 -9
  26. data/spec/controllers/purchase_requests_controller_spec.rb +4 -4
  27. data/spec/dummy/app/controllers/application_controller.rb +7 -4
  28. data/spec/dummy/app/models/user.rb +2 -3
  29. data/spec/dummy/config/application.rb +7 -24
  30. data/spec/dummy/config/environments/development.rb +22 -18
  31. data/spec/dummy/config/environments/production.rb +46 -34
  32. data/spec/dummy/config/environments/test.rb +21 -14
  33. data/spec/dummy/db/migrate/149_create_message_templates.rb +18 -0
  34. data/spec/dummy/db/migrate/154_create_messages.rb +23 -0
  35. data/spec/dummy/db/migrate/20080819181903_create_message_requests.rb +18 -0
  36. data/spec/dummy/db/migrate/20081212151614_create_bookmark_stats.rb +0 -3
  37. data/spec/dummy/db/migrate/20110913115320_add_lft_and_rgt_to_message.rb +11 -0
  38. data/spec/dummy/db/migrate/20120125050502_add_depth_to_message.rb +6 -0
  39. data/spec/dummy/db/migrate/20140110122216_create_user_import_files.rb +1 -1
  40. data/spec/dummy/db/migrate/20140518111006_create_message_transitions.rb +18 -0
  41. data/spec/dummy/db/migrate/20140518135713_create_message_request_transitions.rb +18 -0
  42. data/spec/dummy/db/migrate/20140524074813_create_user_import_file_transitions.rb +5 -1
  43. data/spec/dummy/db/migrate/20140524135607_create_bookmark_stat_transitions.rb +5 -1
  44. data/spec/dummy/db/migrate/20140709113905_create_user_export_file_transitions.rb +5 -1
  45. data/spec/dummy/db/migrate/20140821151023_create_colors.rb +14 -0
  46. data/spec/dummy/db/migrate/20141013152011_add_missing_unique_indices.acts_as_taggable_on_engine.rb +20 -0
  47. data/spec/dummy/db/migrate/20141013152013_add_missing_taggable_index.acts_as_taggable_on_engine.rb +10 -0
  48. data/spec/dummy/db/migrate/20150506105356_add_error_message_to_user_import_result.rb +5 -0
  49. data/spec/dummy/db/migrate/20150924115059_create_withdraws.rb +13 -0
  50. data/spec/dummy/db/migrate/20151213070943_add_translation_table_to_library_group.rb +13 -0
  51. data/spec/dummy/db/migrate/20151213072705_add_footer_banner_to_library_group.rb +9 -0
  52. data/spec/dummy/db/migrate/20160610093229_add_html_snippet_to_library_group.rb +5 -0
  53. data/spec/dummy/db/migrate/20160627232219_add_most_recent_to_user_import_file_transitions.rb +9 -0
  54. data/spec/dummy/db/migrate/20160627232316_add_most_recent_to_user_export_file_transitions.rb +9 -0
  55. data/spec/dummy/db/migrate/20160703185015_add_most_recent_to_message_transitions.rb +9 -0
  56. data/spec/dummy/db/migrate/20160813191647_add_max_number_of_results_to_library_group.rb +5 -0
  57. data/spec/dummy/db/migrate/20160813191733_add_family_name_first_to_library_group.rb +5 -0
  58. data/spec/dummy/db/migrate/20160813192542_add_pub_year_facet_range_interval_to_library_group.rb +5 -0
  59. data/spec/dummy/db/migrate/20160813203039_add_user_id_to_library_group.rb +5 -0
  60. data/spec/dummy/db/migrate/20160814165332_add_most_recent_to_message_request_transitions.rb +9 -0
  61. data/spec/dummy/db/migrate/20160815045420_add_most_recent_to_bookmark_stat_transitions.rb +9 -0
  62. data/spec/dummy/db/schema.rb +123 -10
  63. data/spec/fixtures/library_groups.yml +1 -0
  64. data/spec/fixtures/order_list_transitions.yml +10 -6
  65. data/spec/fixtures/order_lists.yml +2 -3
  66. data/spec/fixtures/orders.yml +3 -4
  67. data/spec/fixtures/purchase_requests.yml +6 -7
  68. data/spec/models/order_list_spec.rb +3 -4
  69. data/spec/models/order_spec.rb +4 -6
  70. data/spec/models/purchase_request_spec.rb +7 -9
  71. data/spec/rails_helper.rb +53 -0
  72. data/spec/spec_helper.rb +82 -43
  73. data/spec/support/devise.rb +2 -2
  74. metadata +261 -194
  75. data/app/models/enju_purchase_request/ability.rb +0 -30
  76. data/lib/enju_purchase_request/user.rb +0 -14
  77. data/spec/dummy/app/models/ability.rb +0 -30
  78. data/spec/dummy/app/views/page/403.html.erb +0 -9
  79. data/spec/dummy/app/views/page/403.mobile.erb +0 -5
  80. data/spec/dummy/app/views/page/403.xml.erb +0 -4
  81. data/spec/dummy/app/views/page/404.html.erb +0 -9
  82. data/spec/dummy/app/views/page/404.mobile.erb +0 -5
  83. data/spec/dummy/app/views/page/404.xml.erb +0 -4
  84. data/spec/dummy/config/application.yml +0 -38
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
3
  describe PurchaseRequestsController do
4
4
  fixtures :all
@@ -193,7 +193,7 @@ describe PurchaseRequestsController do
193
193
  describe "When not logged in" do
194
194
  it "should not assign the requested purchase_request as @purchase_request" do
195
195
  get :new
196
- assigns(:purchase_request).should_not be_valid
196
+ assigns(:purchase_request).should be_nil
197
197
  response.should redirect_to(new_user_session_url)
198
198
  end
199
199
  end
@@ -347,7 +347,7 @@ describe PurchaseRequestsController do
347
347
  describe "with valid params" do
348
348
  it "assigns a newly created purchase_request as @purchase_request" do
349
349
  post :create, :purchase_request => @attrs
350
- assigns(:purchase_request).should_not be_valid
350
+ assigns(:purchase_request).should be_nil
351
351
  end
352
352
 
353
353
  it "should redirect to new_user_session_url" do
@@ -359,7 +359,7 @@ describe PurchaseRequestsController do
359
359
  describe "with invalid params" do
360
360
  it "assigns a newly created but unsaved purchase_request as @purchase_request" do
361
361
  post :create, :purchase_request => @invalid_attrs
362
- assigns(:purchase_request).should_not be_valid
362
+ assigns(:purchase_request).should be_nil
363
363
  end
364
364
 
365
365
  it "should redirect to new_user_session_url" do
@@ -1,7 +1,10 @@
1
1
  class ApplicationController < ActionController::Base
2
2
  protect_from_forgery
3
- enju_leaf
4
- enju_biblio
5
- enju_library
6
- enju_purchase_request
3
+ include EnjuLibrary::Controller
4
+ include EnjuBiblio::Controller
5
+ include EnjuPurchaseRequest::Controller
6
+ before_action :set_paper_trail_whodunnit
7
+ after_action :verify_authorized
8
+
9
+ include Pundit
7
10
  end
@@ -1,9 +1,8 @@
1
- # -*- encoding: utf-8 -*-
2
1
  class User < ActiveRecord::Base
3
2
  devise :database_authenticatable, #:registerable,
4
3
  :recoverable, :rememberable, :trackable, #, :validatable
5
4
  :lockable, :lock_strategy => :none, :unlock_strategy => :none
6
5
 
7
- enju_leaf_user_model
8
- enju_purchase_request_user_model
6
+ include EnjuSeed::EnjuUser
7
+ include EnjuPurchaseRequest::EnjuUser
9
8
  end
@@ -2,8 +2,11 @@ require File.expand_path('../boot', __FILE__)
2
2
 
3
3
  require 'rails/all'
4
4
 
5
- Bundler.require
6
- require "enju_purchase_request"
5
+ Bundler.require(*Rails.groups)
6
+ require 'enju_purchase_request'
7
+ require 'enju_leaf'
8
+ require 'globalize'
9
+ require 'globalize-accessors'
7
10
 
8
11
  module Dummy
9
12
  class Application < Rails::Application
@@ -11,16 +14,6 @@ module Dummy
11
14
  # Application configuration should go into files in config/initializers
12
15
  # -- all .rb files in that directory are automatically loaded.
13
16
 
14
- # Custom directories with classes and modules you want to be autoloadable.
15
- # config.autoload_paths += %W(#{config.root}/extras)
16
-
17
- # Only load the plugins named here, in the order given (default is alphabetical).
18
- # :all can be used as a placeholder for all plugins not explicitly named.
19
- # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
20
-
21
- # Activate observers that should always be running.
22
- # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
23
-
24
17
  # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
25
18
  # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
26
19
  # config.time_zone = 'Central Time (US & Canada)'
@@ -29,18 +22,8 @@ module Dummy
29
22
  # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
30
23
  # config.i18n.default_locale = :de
31
24
 
32
- # Configure the default encoding used in templates for Ruby 1.9.
33
- config.encoding = "utf-8"
34
-
35
- # Configure sensitive parameters which will be filtered from the log file.
36
- config.filter_parameters += [:password]
37
-
38
- # Enable the asset pipeline
39
- config.assets.enabled = true
40
-
41
- # Version of your assets, change this if you want to expire all your assets
42
- config.assets.version = '1.0'
25
+ # Do not swallow errors in after_commit/after_rollback callbacks.
26
+ config.active_record.raise_in_transactional_callbacks = true
43
27
  end
44
28
  end
45
29
 
46
- require 'enju_leaf'
@@ -1,37 +1,41 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
3
 
4
4
  # In the development environment your application's code is reloaded on
5
5
  # every request. This slows down response time but is perfect for development
6
6
  # since you don't have to restart the web server when you make code changes.
7
7
  config.cache_classes = false
8
8
 
9
- # Log error messages when you accidentally call methods on nil.
10
- config.whiny_nils = true
9
+ # Do not eager load code on boot.
10
+ config.eager_load = false
11
11
 
12
- # Show full error reports and disable caching
12
+ # Show full error reports and disable caching.
13
13
  config.consider_all_requests_local = true
14
14
  config.action_controller.perform_caching = false
15
15
 
16
- # Don't care if the mailer can't send
16
+ # Don't care if the mailer can't send.
17
17
  config.action_mailer.raise_delivery_errors = false
18
18
 
19
- # Print deprecation notices to the Rails logger
19
+ # Print deprecation notices to the Rails logger.
20
20
  config.active_support.deprecation = :log
21
21
 
22
- # Only use best-standards-support built into browsers
23
- config.action_dispatch.best_standards_support = :builtin
22
+ # Raise an error on page load if there are pending migrations.
23
+ config.active_record.migration_error = :page_load
24
24
 
25
- # Raise exception on mass assignment protection for Active Record models
26
- config.active_record.mass_assignment_sanitizer = :strict
25
+ # Debug mode disables concatenation and preprocessing of assets.
26
+ # This option may cause significant delays in view rendering with a large
27
+ # number of complex assets.
28
+ config.assets.debug = true
27
29
 
28
- # Log the query plan for queries taking more than this (works
29
- # with SQLite, MySQL, and PostgreSQL)
30
- config.active_record.auto_explain_threshold_in_seconds = 0.5
30
+ # Asset digests allow you to set far-future HTTP expiration dates on all assets,
31
+ # yet still be able to expire them through the digest params.
32
+ config.assets.digest = true
31
33
 
32
- # Do not compress assets
33
- config.assets.compress = false
34
+ # Adds additional error checking when serving assets at runtime.
35
+ # Checks for improperly declared sprockets dependencies.
36
+ # Raises helpful error messages.
37
+ config.assets.raise_runtime_errors = true
34
38
 
35
- # Expands the lines which load the assets
36
- config.assets.debug = true
39
+ # Raises error for missing translations
40
+ # config.action_view.raise_on_missing_translations = true
37
41
  end
@@ -1,67 +1,79 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
3
 
4
- # Code is not reloaded between requests
4
+ # Code is not reloaded between requests.
5
5
  config.cache_classes = true
6
6
 
7
- # Full error reports are disabled and caching is turned on
7
+ # Eager load code on boot. This eager loads most of Rails and
8
+ # your application in memory, allowing both threaded web servers
9
+ # and those relying on copy on write to perform better.
10
+ # Rake tasks automatically ignore this option for performance.
11
+ config.eager_load = true
12
+
13
+ # Full error reports are disabled and caching is turned on.
8
14
  config.consider_all_requests_local = false
9
15
  config.action_controller.perform_caching = true
10
16
 
11
- # Disable Rails's static asset server (Apache or nginx will already do this)
12
- config.serve_static_assets = false
17
+ # Enable Rack::Cache to put a simple HTTP cache in front of your application
18
+ # Add `rack-cache` to your Gemfile before enabling this.
19
+ # For large-scale production use, consider using a caching reverse proxy like
20
+ # NGINX, varnish or squid.
21
+ # config.action_dispatch.rack_cache = true
22
+
23
+ # Disable serving static files from the `/public` folder by default since
24
+ # Apache or NGINX already handles this.
25
+ config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
13
26
 
14
- # Compress JavaScripts and CSS
15
- config.assets.compress = true
27
+ # Compress JavaScripts and CSS.
28
+ config.assets.js_compressor = :uglifier
29
+ # config.assets.css_compressor = :sass
16
30
 
17
- # Don't fallback to assets pipeline if a precompiled asset is missed
31
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
18
32
  config.assets.compile = false
19
33
 
20
- # Generate digests for assets URLs
34
+ # Asset digests allow you to set far-future HTTP expiration dates on all assets,
35
+ # yet still be able to expire them through the digest params.
21
36
  config.assets.digest = true
22
37
 
23
- # Defaults to Rails.root.join("public/assets")
24
- # config.assets.manifest = YOUR_PATH
38
+ # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
25
39
 
26
- # Specifies the header that your server uses for sending files
27
- # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
28
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
40
+ # Specifies the header that your server uses for sending files.
41
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
42
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
29
43
 
30
44
  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
31
45
  # config.force_ssl = true
32
46
 
33
- # See everything in the log (default is :info)
34
- # config.log_level = :debug
47
+ # Use the lowest log level to ensure availability of diagnostic information
48
+ # when problems arise.
49
+ config.log_level = :debug
35
50
 
36
- # Prepend all log lines with the following tags
51
+ # Prepend all log lines with the following tags.
37
52
  # config.log_tags = [ :subdomain, :uuid ]
38
53
 
39
- # Use a different logger for distributed setups
54
+ # Use a different logger for distributed setups.
40
55
  # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
41
56
 
42
- # Use a different cache store in production
57
+ # Use a different cache store in production.
43
58
  # config.cache_store = :mem_cache_store
44
59
 
45
- # Enable serving of images, stylesheets, and JavaScripts from an asset server
46
- # config.action_controller.asset_host = "http://assets.example.com"
47
-
48
- # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
49
- # config.assets.precompile += %w( search.js )
60
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
61
+ # config.action_controller.asset_host = 'http://assets.example.com'
50
62
 
51
- # Disable delivery errors, bad email addresses will be ignored
63
+ # Ignore bad email addresses and do not raise email delivery errors.
64
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
52
65
  # config.action_mailer.raise_delivery_errors = false
53
66
 
54
- # Enable threaded mode
55
- # config.threadsafe!
56
-
57
67
  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
58
- # the I18n.default_locale when a translation can not be found)
68
+ # the I18n.default_locale when a translation cannot be found).
59
69
  config.i18n.fallbacks = true
60
70
 
61
- # Send deprecation notices to registered listeners
71
+ # Send deprecation notices to registered listeners.
62
72
  config.active_support.deprecation = :notify
63
73
 
64
- # Log the query plan for queries taking more than this (works
65
- # with SQLite, MySQL, and PostgreSQL)
66
- # config.active_record.auto_explain_threshold_in_seconds = 0.5
74
+ # Use default logging formatter so that PID and timestamp are not suppressed.
75
+ config.log_formatter = ::Logger::Formatter.new
76
+
77
+ # Do not dump schema after migrations.
78
+ config.active_record.dump_schema_after_migration = false
67
79
  end
@@ -1,5 +1,5 @@
1
- Dummy::Application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb
1
+ Rails.application.configure do
2
+ # Settings specified here will take precedence over those in config/application.rb.
3
3
 
4
4
  # The test environment is used exclusively to run your application's
5
5
  # test suite. You never need to work with it otherwise. Remember that
@@ -7,31 +7,38 @@ Dummy::Application.configure do
7
7
  # and recreated between test runs. Don't rely on the data there!
8
8
  config.cache_classes = true
9
9
 
10
- # Configure static asset server for tests with Cache-Control for performance
11
- config.serve_static_assets = true
12
- config.static_cache_control = "public, max-age=3600"
10
+ # Do not eager load code on boot. This avoids loading your whole application
11
+ # just for the purpose of running a single test. If you are using a tool that
12
+ # preloads Rails for running tests, you may have to set it to true.
13
+ config.eager_load = false
13
14
 
14
- # Log error messages when you accidentally call methods on nil
15
- config.whiny_nils = true
15
+ # Configure static file server for tests with Cache-Control for performance.
16
+ config.serve_static_files = true
17
+ config.static_cache_control = 'public, max-age=3600'
16
18
 
17
- # Show full error reports and disable caching
19
+ # Show full error reports and disable caching.
18
20
  config.consider_all_requests_local = true
19
21
  config.action_controller.perform_caching = false
20
22
 
21
- # Raise exceptions instead of rendering exception templates
23
+ # Raise exceptions instead of rendering exception templates.
22
24
  config.action_dispatch.show_exceptions = false
23
25
 
24
- # Disable request forgery protection in test environment
25
- config.action_controller.allow_forgery_protection = false
26
+ # Disable request forgery protection in test environment.
27
+ config.action_controller.allow_forgery_protection = false
26
28
 
27
29
  # Tell Action Mailer not to deliver emails to the real world.
28
30
  # The :test delivery method accumulates sent emails in the
29
31
  # ActionMailer::Base.deliveries array.
30
32
  config.action_mailer.delivery_method = :test
31
33
 
32
- # Raise exception on mass assignment protection for Active Record models
33
- #config.active_record.mass_assignment_sanitizer = :strict
34
+ # Randomize the order test cases are executed.
35
+ config.active_support.test_order = :random
34
36
 
35
- # Print deprecation notices to the stderr
37
+ # Print deprecation notices to the stderr.
36
38
  config.active_support.deprecation = :stderr
39
+
40
+ # Raises error for missing translations
41
+ # config.action_view.raise_on_missing_translations = true
42
+
43
+ config.action_mailer.default_url_options = {:host => 'localhost:3000'}
37
44
  end
@@ -0,0 +1,18 @@
1
+ class CreateMessageTemplates < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :message_templates do |t|
4
+ t.string :status, :null => false
5
+ t.text :title, :null => false
6
+ t.text :body, :null => false
7
+ t.integer :position
8
+ t.string :locale, :default => I18n.default_locale.to_s
9
+
10
+ t.timestamps
11
+ end
12
+ add_index :message_templates, :status, :unique => true
13
+ end
14
+
15
+ def self.down
16
+ drop_table :message_templates
17
+ end
18
+ end
@@ -0,0 +1,23 @@
1
+ class CreateMessages < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :messages, :force => true do |t|
4
+ t.datetime :read_at
5
+ t.integer :receiver_id, :sender_id
6
+ t.string :subject, :null => false
7
+ t.text :body
8
+ t.integer :message_request_id
9
+ t.integer :parent_id
10
+
11
+ t.timestamps
12
+ end
13
+
14
+ add_index :messages, :sender_id
15
+ add_index :messages, :receiver_id
16
+ add_index :messages, :message_request_id
17
+ add_index :messages, :parent_id
18
+ end
19
+
20
+ def self.down
21
+ drop_table :messages
22
+ end
23
+ end
@@ -0,0 +1,18 @@
1
+ class CreateMessageRequests < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :message_requests do |t|
4
+ t.integer :sender_id
5
+ t.integer :receiver_id
6
+ t.integer :message_template_id
7
+ t.datetime :sent_at
8
+ t.datetime :deleted_at
9
+ t.text :body
10
+
11
+ t.timestamps
12
+ end
13
+ end
14
+
15
+ def self.down
16
+ drop_table :message_requests
17
+ end
18
+ end
@@ -6,11 +6,8 @@ class CreateBookmarkStats < ActiveRecord::Migration
6
6
  t.datetime :started_at
7
7
  t.datetime :completed_at
8
8
  t.text :note
9
- t.string :state
10
9
 
11
10
  t.timestamps
12
11
  end
13
-
14
- add_index :bookmark_stats, :state
15
12
  end
16
13
  end
@@ -0,0 +1,11 @@
1
+ class AddLftAndRgtToMessage < ActiveRecord::Migration
2
+ def self.up
3
+ add_column :messages, :lft, :integer
4
+ add_column :messages, :rgt, :integer
5
+ end
6
+
7
+ def self.down
8
+ remove_column :messages, :rgt
9
+ remove_column :messages, :lft
10
+ end
11
+ end
@@ -0,0 +1,6 @@
1
+ class AddDepthToMessage < ActiveRecord::Migration
2
+ def change
3
+ add_column :messages, :depth, :integer
4
+
5
+ end
6
+ end
@@ -6,7 +6,7 @@ class CreateUserImportFiles < ActiveRecord::Migration
6
6
  t.datetime :executed_at
7
7
  t.string :user_import_file_name
8
8
  t.string :user_import_content_type
9
- t.string :user_import_file_size
9
+ t.integer :user_import_file_size
10
10
  t.datetime :user_import_updated_at
11
11
  t.string :user_import_fingerprint
12
12
  t.string :edit_mode
@@ -0,0 +1,18 @@
1
+ class CreateMessageTransitions < ActiveRecord::Migration
2
+ def change
3
+ create_table :message_transitions do |t|
4
+ t.string :to_state
5
+ if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
6
+ t.text :metadata
7
+ else
8
+ t.text :metadata, default: "{}"
9
+ end
10
+ t.integer :sort_key
11
+ t.integer :message_id
12
+ t.timestamps
13
+ end
14
+
15
+ add_index :message_transitions, :message_id
16
+ add_index :message_transitions, [:sort_key, :message_id], unique: true
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ class CreateMessageRequestTransitions < ActiveRecord::Migration
2
+ def change
3
+ create_table :message_request_transitions do |t|
4
+ t.string :to_state
5
+ if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
6
+ t.text :metadata
7
+ else
8
+ t.text :metadata, default: "{}"
9
+ end
10
+ t.integer :sort_key
11
+ t.integer :message_request_id
12
+ t.timestamps
13
+ end
14
+
15
+ add_index :message_request_transitions, :message_request_id
16
+ add_index :message_request_transitions, [:sort_key, :message_request_id], unique: true, name: "index_message_request_transitions_on_sort_key_and_request_id"
17
+ end
18
+ end
@@ -2,7 +2,11 @@ class CreateUserImportFileTransitions < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :user_import_file_transitions do |t|
4
4
  t.string :to_state
5
- t.text :metadata, default: "{}"
5
+ if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
6
+ t.text :metadata
7
+ else
8
+ t.text :metadata, default: "{}"
9
+ end
6
10
  t.integer :sort_key
7
11
  t.integer :user_import_file_id
8
12
  t.timestamps
@@ -2,7 +2,11 @@ class CreateBookmarkStatTransitions < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :bookmark_stat_transitions do |t|
4
4
  t.string :to_state
5
- t.text :metadata, default: "{}"
5
+ if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
6
+ t.text :metadata
7
+ else
8
+ t.text :metadata, default: "{}"
9
+ end
6
10
  t.integer :sort_key
7
11
  t.integer :bookmark_stat_id
8
12
  t.timestamps
@@ -2,7 +2,11 @@ class CreateUserExportFileTransitions < ActiveRecord::Migration
2
2
  def change
3
3
  create_table :user_export_file_transitions do |t|
4
4
  t.string :to_state
5
- t.text :metadata, default: "{}"
5
+ if ActiveRecord::Base.configurations[Rails.env]["adapter"].try(:match, /mysql/)
6
+ t.text :metadata
7
+ else
8
+ t.text :metadata, default: "{}"
9
+ end
6
10
  t.integer :sort_key
7
11
  t.integer :user_export_file_id
8
12
  t.timestamps
@@ -0,0 +1,14 @@
1
+ class CreateColors < ActiveRecord::Migration
2
+ def change
3
+ create_table :colors do |t|
4
+ t.integer :library_group_id
5
+ t.string :property
6
+ t.string :code
7
+ t.integer :position
8
+
9
+ t.timestamps
10
+ end
11
+
12
+ add_index :colors, :library_group_id
13
+ end
14
+ end
@@ -0,0 +1,20 @@
1
+ # This migration comes from acts_as_taggable_on_engine (originally 2)
2
+ class AddMissingUniqueIndices < ActiveRecord::Migration
3
+ def self.up
4
+ add_index :tags, :name, unique: true
5
+
6
+ remove_index :taggings, :tag_id
7
+ remove_index :taggings, [:taggable_id, :taggable_type, :context]
8
+ add_index :taggings,
9
+ [:tag_id, :taggable_id, :taggable_type, :context, :tagger_id, :tagger_type],
10
+ unique: true, name: 'taggings_idx'
11
+ end
12
+
13
+ def self.down
14
+ remove_index :tags, :name
15
+
16
+ remove_index :taggings, name: 'taggings_idx'
17
+ add_index :taggings, :tag_id
18
+ add_index :taggings, [:taggable_id, :taggable_type, :context]
19
+ end
20
+ end
@@ -0,0 +1,10 @@
1
+ # This migration comes from acts_as_taggable_on_engine (originally 4)
2
+ class AddMissingTaggableIndex < ActiveRecord::Migration
3
+ def self.up
4
+ add_index :taggings, [:taggable_id, :taggable_type, :context]
5
+ end
6
+
7
+ def self.down
8
+ remove_index :taggings, [:taggable_id, :taggable_type, :context]
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ class AddErrorMessageToUserImportResult < ActiveRecord::Migration
2
+ def change
3
+ add_column :user_import_results, :error_message, :text
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ class CreateWithdraws < ActiveRecord::Migration
2
+ def change
3
+ create_table :withdraws do |t|
4
+ t.integer :basket_id
5
+ t.integer :item_id
6
+ t.integer :librarian_id
7
+
8
+ t.timestamps null: false
9
+ end
10
+ add_index :withdraws, :basket_id
11
+ add_index :withdraws, :item_id
12
+ end
13
+ end
@@ -0,0 +1,13 @@
1
+ class AddTranslationTableToLibraryGroup < ActiveRecord::Migration
2
+ def up
3
+ LibraryGroup.create_translation_table!({
4
+ login_banner: :text
5
+ }, {
6
+ migrate_data: true
7
+ })
8
+ end
9
+
10
+ def down
11
+ LibraryGroup.drop_translation_table! migrate_data: true
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ class AddFooterBannerToLibraryGroup < ActiveRecord::Migration
2
+ def up
3
+ LibraryGroup.add_translation_fields! footer_banner: :text
4
+ end
5
+
6
+ def down
7
+ remove_column :library_group_translations, :footer_banner
8
+ end
9
+ end
@@ -0,0 +1,5 @@
1
+ class AddHtmlSnippetToLibraryGroup < ActiveRecord::Migration
2
+ def change
3
+ add_column :library_groups, :html_snippet, :text
4
+ end
5
+ end
@@ -0,0 +1,9 @@
1
+ class AddMostRecentToUserImportFileTransitions < ActiveRecord::Migration
2
+ def up
3
+ add_column :user_import_file_transitions, :most_recent, :boolean, null: true
4
+ end
5
+
6
+ def down
7
+ remove_column :user_import_file_transitions, :most_recent
8
+ end
9
+ end