enju_manifestation_viewer 0.3.5 → 0.4.0.beta.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +4 -3
  3. data/app/helpers/book_jacket_helper.rb +94 -0
  4. data/app/helpers/manifestation_viewer_helper.rb +18 -0
  5. data/app/models/concerns/enju_manifestation_viewer/enju_manifestation.rb +41 -0
  6. data/lib/enju_manifestation_viewer/version.rb +1 -1
  7. data/spec/dummy/app/assets/javascripts/application.js +0 -1
  8. data/spec/dummy/app/helpers/application_helper.rb +0 -1
  9. data/spec/dummy/app/models/user.rb +2 -1
  10. data/spec/dummy/bin/bundle +1 -1
  11. data/spec/dummy/bin/setup +1 -3
  12. data/spec/dummy/bin/update +4 -2
  13. data/spec/dummy/bin/yarn +3 -3
  14. data/spec/dummy/config/application.rb +1 -2
  15. data/spec/dummy/config/database.yml +70 -9
  16. data/spec/dummy/config/initializers/assets.rb +0 -1
  17. data/spec/dummy/db/migrate/20100606065209_create_user_has_roles.rb +2 -4
  18. data/spec/dummy/db/migrate/20130221154434_add_additional_attributes_to_user.rb +1 -1
  19. data/spec/dummy/db/migrate/20140122054321_create_profiles.rb +4 -5
  20. data/spec/dummy/db/migrate/20140524074813_create_user_import_file_transitions.rb +1 -1
  21. data/spec/dummy/db/migrate/20140709113905_create_user_export_file_transitions.rb +1 -1
  22. data/spec/dummy/db/migrate/20180107160726_add_constraints_to_most_recent_for_user_import_file_transitions.rb +1 -1
  23. data/spec/dummy/db/migrate/20180107160740_add_constraints_to_most_recent_for_user_export_file_transitions.rb +1 -1
  24. data/spec/dummy/db/migrate/20190630113817_add_display_name_translations_to_library_group.rb +12 -0
  25. data/spec/dummy/db/migrate/20190630115523_add_login_banner_translations_to_library_group.rb +6 -0
  26. data/spec/dummy/db/migrate/20190630151446_add_display_name_translations_to_role.rb +5 -0
  27. data/spec/dummy/db/migrate/20190712163038_add_display_name_translations_to_carrier_type.rb +21 -0
  28. data/spec/dummy/db/migrate/20190713114940_add_profile_id_to_user.rb +5 -0
  29. data/spec/dummy/db/migrate/20190713115451_add_full_name_translations_to_profile.rb +5 -0
  30. data/spec/dummy/db/schema.rb +115 -139
  31. data/spec/fixtures/identifier_types.yml +17 -4
  32. data/spec/fixtures/identifiers.yml +1 -1
  33. data/spec/fixtures/library_groups.yml +39 -18
  34. data/spec/helpers/book_jacket_helper_spec.rb +1 -1
  35. data/spec/rails_helper.rb +5 -8
  36. data/spec/support/devise.rb +2 -2
  37. metadata +29 -188
  38. data/spec/dummy/app/assets/images/icons/book.png +0 -0
  39. data/spec/dummy/db/migrate/20151213070943_add_translation_table_to_library_group.rb +0 -25
  40. data/spec/dummy/db/migrate/20151213072705_add_footer_banner_to_library_group.rb +0 -22
  41. data/spec/dummy/db/migrate/20190818075603_add_memo_to_manifestation.rb +0 -5
  42. data/spec/dummy/db/migrate/20190818075628_add_memo_to_item.rb +0 -5
  43. data/spec/dummy/db/migrate/20191219122214_create_custom_properties.rb +0 -12
  44. data/spec/dummy/db/migrate/20200425072340_create_manifestation_custom_properties.rb +0 -12
  45. data/spec/dummy/db/migrate/20200425072349_create_item_custom_properties.rb +0 -12
  46. data/spec/dummy/db/migrate/20200425074758_create_manifestation_custom_values.rb +0 -12
  47. data/spec/dummy/db/migrate/20200425074822_create_item_custom_values.rb +0 -12
  48. data/spec/factories/manifestation.rb +0 -14
  49. data/spec/fixtures/carrier_types.yml +0 -54
  50. data/spec/fixtures/content_types.yml +0 -98
  51. data/spec/fixtures/frequencies.yml +0 -68
  52. data/spec/fixtures/languages.yml +0 -1900
  53. data/spec/fixtures/libraries.yml +0 -102
  54. data/spec/fixtures/profiles.yml +0 -78
  55. data/spec/fixtures/roles.yml +0 -21
  56. data/spec/fixtures/user_groups.yml +0 -45
  57. data/spec/fixtures/user_has_roles.yml +0 -40
  58. data/spec/fixtures/users.yml +0 -51
  59. data/spec/models/manifestation_spec.rb +0 -13
  60. data/spec/system/library_groups_spec.rb +0 -21
  61. data/spec/system/manifestations_spec.rb +0 -39
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb833e65cb108463339ca8e5a7e39825a74fa0d0399a3d002e210706d5eadebb
4
- data.tar.gz: d4280d4dd553a893672e6c3f4180961be8638ae01a6f448aa01545e0772d353e
3
+ metadata.gz: 5283c1ddccbc5bfa2a3c51970b406cc9de02bb889f2a94cbbd01bd1965199a9a
4
+ data.tar.gz: ed69d4378df4581a00072021007637ec679b50a6742d4020781d4f2a3bb74805
5
5
  SHA512:
6
- metadata.gz: b9a21cbc82b3922b9ea01d356bed04d8797cbc947c03db985f35893f5172504dfed5620b13b745f046c60c28e667bdd846e15941e564c350bcb7668fc7e2e7c6
7
- data.tar.gz: 27fa80f8e27184e94b9c3c3fea4ce63e278b8f66a7adfbd300e8886474b1602efc302ee91ea217cdf124d942335de43234c1f2e37d8a424878f3f00802f55b94
6
+ metadata.gz: 79aa68beed7af3ee53f12ea1d061eb17796983785a7d5748dad279748a77ecd4f701fbb050d34338196330c77bf0784f1f5f446605e902dec6eec3b78f8bb128
7
+ data.tar.gz: 5840a687b46bd47f0338e7d756d990650225b38d31d2fb1f6ae56e92233cc4076f7ab74fa8d395c4c67b4420a437f06fd62ca50911694b7d6ceefcdc2a2b8725
data/README.md CHANGED
@@ -1,10 +1,11 @@
1
1
  # EnjuManifestationViewer
2
- [![Travis CI](https://travis-ci.com/next-l/enju_manifestation_viewer.svg?branch=1.3)](https://travis-ci.com/next-l/enju_manifestation_viewer)
3
- [![Coverage Status](https://coveralls.io/repos/github/next-l/enju_enju_manifestation_viewer/badge.svg?branch=1.3)](https://coveralls.io/github/next-l/enju_enju_manifestation_viewer?branch=1.3)
4
- [![security](https://hakiri.io/github/next-l/enju_enju_manifestation_viewer/1.3.svg)](https://hakiri.io/github/next-l/enju_enju_manifestation_viewer/1.3)
2
+ [![CircleCI](https://circleci.com/gh/next-l/enju_manifestation_viewer.svg?style=svg)](https://circleci.com/gh/next-l/enju_manifestation_viewer)
3
+ [![Coverage Status](https://coveralls.io/repos/github/next-l/enju_manifestation_viewer/badge.svg?branch=master)](https://coveralls.io/github/next-l/enju_manifestation_viewer?branch=master)
4
+ [![security](https://hakiri.io/github/next-l/enju_manifestation_viewer/master.svg)](https://hakiri.io/github/next-l/enju_manifestation_viewer/master)
5
5
 
6
6
  This project rocks and uses MIT-LICENSE.
7
7
 
8
8
  ## 製作者・貢献者 (Authors and contributors)
9
9
  * [TANABE, Kosuke](https://github.com/nabeta) ([@nabeta](https://twitter.com/nabeta))
10
10
  * [Project Next-L](https://www.next-l.jp) ([@ProjectNextL](https://twitter.com/ProjectNextL))
11
+
@@ -0,0 +1,94 @@
1
+ module BookJacketHelper
2
+ def book_jacket(manifestation)
3
+ if manifestation.picture_files.exists?
4
+ link = ''
5
+ manifestation.picture_files.each_with_index do |picture_file, i|
6
+ if i == 0
7
+ link += link_to(show_image(picture_file, size: :thumb), picture_file_path(picture_file, format: :download), rel: "manifestation_#{manifestation.id}")
8
+ else
9
+ link += content_tag :span, style: "display: none" do
10
+ link_to(show_image(picture_file, size: :thumb), picture_file_path(picture_file, format: :download), rel: "manifestation_#{manifestation.id}")
11
+ end
12
+ end
13
+ end
14
+ return link.html_safe
15
+ else
16
+ link = book_jacket_tag(manifestation)
17
+ unless link
18
+ link = screenshot_tag(manifestation)
19
+ end
20
+ end
21
+
22
+ unless link
23
+ link = link_to image_tag('unknown_resource.png', width: '100', height: '100', alt: '*', itemprop: 'image'), manifestation
24
+ end
25
+ link
26
+ end
27
+
28
+ def screenshot_tag(manifestation, generator = LibraryGroup.site_config.screenshot_generator)
29
+ return nil unless manifestation.try(:access_address)
30
+ case generator
31
+ when "mozshot"
32
+ link_to image_tag("http://mozshot.nemui.org/shot?#{manifestation.access_address}", width: 128, height: 128, alt: manifestation.original_title, border: 0, itemprop: 'image'), manifestation.access_address
33
+ when "simpleapi"
34
+ link_to image_tag("http://img.simpleapi.net/small/#{manifestation.access_address}", width: 128, height: 128, alt: manifestation.original_title, border: 0, itemprop: 'image'), manifestation.access_address
35
+ when "heartrails"
36
+ link_to image_tag("http://capture.heartrails.com/medium?#{manifestation.access_address}", width: 120, height: 90, alt: manifestation.original_title, border: 0, itemprop: 'image'), manifestation.access_address
37
+ when "thumbalizr"
38
+ link_to image_tag("http://api.thumbalizr.com/?url=#{manifestation.access_address}&width=128", width: 128, height: 144, alt: manifestation.original_title, border: 0, itemprop: 'image'), manifestation.access_address
39
+ end
40
+ end
41
+
42
+ def book_jacket_tag(manifestation, generator = LibraryGroup.site_config.book_jacket_source)
43
+ return nil unless manifestation
44
+ case generator
45
+ when "amazon"
46
+ return nil unless LibraryGroup.site_config.settings[:amazon_hostname]
47
+ book_jacket = manifestation.amazon_book_jacket
48
+ if book_jacket
49
+ link_to image_tag(book_jacket[:url], width: book_jacket[:width], height: book_jacket[:height], alt: manifestation.original_title, class: 'book_jacket', itemprop: 'image'), "http://#{LibraryGroup.site_config.settings[:amazon_hostname]}/dp/#{book_jacket[:asin]}"
50
+ end
51
+ when "google"
52
+ render partial: 'manifestations/google_book_thumbnail', locals: {manifestation: manifestation}
53
+ when "hanmotocom"
54
+ render partial: 'manifestations/hanmotocom_thumbnail', locals: {manifestation: manifestation}
55
+ end
56
+ end
57
+
58
+ def amazon_link(asin, hostname = LibraryGroup.site_config.settings[:amazon_hostname])
59
+ return nil if asin.blank?
60
+ "http://#{hostname}/dp/#{asin}"
61
+ end
62
+
63
+ def book_jacket_source_link(source = LibraryGroup.site_config.book_jacket_source)
64
+ case source
65
+ when "google"
66
+ link_to "Google Books", "http://books.google.com/"
67
+ when "amazon"
68
+ link_to "Amazon Web Services", "http://aws.amazon.com/"
69
+ end
70
+ end
71
+
72
+ def book_jacket_header(source = LibraryGroup.site_config.book_jacket_source)
73
+ string = ''
74
+ case source
75
+ when "google"
76
+ string << javascript_tag(nil, src: "https://www.google.com/jsapi")
77
+ string << render('manifestations/google_book_thumbnail_header')
78
+ end
79
+ string.html_safe
80
+ end
81
+
82
+ def screenshot_generator_link(generator = LibraryGroup.site_config.screenshot_generator)
83
+ case generator
84
+ when "mozshot"
85
+ link_to "MozShot", "http://mozshot.nemui.org/"
86
+ when "simpleapi"
87
+ link_to "SimpleAPI", "http://img.simpleapi.net/"
88
+ when "heartrails"
89
+ link_to "HeartRails Capture", "http://capture.heartrails.com/"
90
+ when "thumbalizr"
91
+ link_to "thumbalizr", "http://www.thumbalizr.com/"
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,18 @@
1
+ module ManifestationViewerHelper
2
+ def google_book_search_preview(isbn)
3
+ render :partial => 'manifestations/google_book_search', :locals => {:isbn => isbn}
4
+ end
5
+
6
+ def embed_content(manifestation)
7
+ case
8
+ when manifestation.youtube_id
9
+ render :partial => 'manifestations/youtube', :locals => {:manifestation => manifestation}
10
+ when manifestation.nicovideo_id
11
+ render :partial => 'manifestations/nicovideo', :locals => {:manifestation => manifestation}
12
+ when manifestation.flickr.present?
13
+ render :partial => 'manifestations/flickr', :locals => {:manifestation => manifestation}
14
+ when manifestation.respond_to?(:ipaper_id)
15
+ render :partial => 'manifestations/scribd', :locals => {:manifestation => manifestation}
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,41 @@
1
+ module EnjuManifestationViewer
2
+ module EnjuManifestation
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+
7
+ def youtube_id
8
+ if access_address
9
+ url = ::Addressable::URI.parse(access_address)
10
+ if url.host =~ /youtube\.com$/ && (url.path == "/watch")
11
+ return CGI.parse(url.query)["v"][0]
12
+ end
13
+ end
14
+ end
15
+
16
+ def nicovideo_id
17
+ if access_address
18
+ url = ::Addressable::URI.parse(access_address)
19
+ if url.host =~ /nicovideo\.jp$/ && url.path =~ /^\/watch/
20
+ return url.path.split("/")[2]
21
+ end
22
+ end
23
+ end
24
+
25
+ def flickr
26
+ if access_address
27
+ url = ::Addressable::URI.parse(access_address)
28
+ paths = url.path.split('/')
29
+ if url.host =~ /^www\.flickr\.com$/ && (paths[1] == 'photos') && paths[2]
30
+ info = {}
31
+ if paths[3] == "sets"
32
+ info[:user] = paths[2]
33
+ info[:set_id] = paths[4]
34
+ return info
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -1,3 +1,3 @@
1
1
  module EnjuManifestationViewer
2
- VERSION = "0.3.5".freeze
2
+ VERSION = "0.4.0.beta.1"
3
3
  end
@@ -10,5 +10,4 @@
10
10
  // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
11
  // about supported directives.
12
12
  //
13
- //= require jquery2
14
13
  //= require_tree .
@@ -1,3 +1,2 @@
1
1
  module ApplicationHelper
2
- include EnjuLeaf::ApplicationHelper
3
2
  end
@@ -1,4 +1,4 @@
1
- class User < ActiveRecord::Base
1
+ class User < ApplicationRecord
2
2
  # Include default devise modules. Others available are:
3
3
  # :token_authenticatable, :encryptable, :confirmable, :lockable, :timeoutable and :omniauthable
4
4
  devise :database_authenticatable, #:registerable,
@@ -10,3 +10,4 @@ class User < ActiveRecord::Base
10
10
  end
11
11
 
12
12
  Item.include(EnjuLibrary::EnjuItem)
13
+ Manifestation.include(EnjuManifestationViewer::EnjuManifestation)
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env ruby
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
3
3
  load Gem.bin_path('bundler', 'bundle')
@@ -1,10 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
- require 'pathname'
3
2
  require 'fileutils'
4
3
  include FileUtils
5
4
 
6
5
  # path to your application root.
7
- APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
+ APP_ROOT = File.expand_path('..', __dir__)
8
7
 
9
8
  def system!(*args)
10
9
  system(*args) || abort("\n== Command #{args} failed ==")
@@ -21,7 +20,6 @@ chdir APP_ROOT do
21
20
  # Install JavaScript dependencies if using Yarn
22
21
  # system('bin/yarn')
23
22
 
24
-
25
23
  # puts "\n== Copying sample files =="
26
24
  # unless File.exist?('config/database.yml')
27
25
  # cp 'config/database.yml.sample', 'config/database.yml'
@@ -1,10 +1,9 @@
1
1
  #!/usr/bin/env ruby
2
- require 'pathname'
3
2
  require 'fileutils'
4
3
  include FileUtils
5
4
 
6
5
  # path to your application root.
7
- APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
+ APP_ROOT = File.expand_path('..', __dir__)
8
7
 
9
8
  def system!(*args)
10
9
  system(*args) || abort("\n== Command #{args} failed ==")
@@ -18,6 +17,9 @@ chdir APP_ROOT do
18
17
  system! 'gem install bundler --conservative'
19
18
  system('bundle check') || system!('bundle install')
20
19
 
20
+ # Install JavaScript dependencies if using Yarn
21
+ # system('bin/yarn')
22
+
21
23
  puts "\n== Updating database =="
22
24
  system! 'bin/rails db:migrate'
23
25
 
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env ruby
2
- VENDOR_PATH = File.expand_path('..', __dir__)
3
- Dir.chdir(VENDOR_PATH) do
2
+ APP_ROOT = File.expand_path('..', __dir__)
3
+ Dir.chdir(APP_ROOT) do
4
4
  begin
5
- exec "yarnpkg #{ARGV.join(" ")}"
5
+ exec "yarnpkg", *ARGV
6
6
  rescue Errno::ENOENT
7
7
  $stderr.puts "Yarn executable was not detected in the system."
8
8
  $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install"
@@ -4,13 +4,12 @@ require 'rails/all'
4
4
 
5
5
  Bundler.require(*Rails.groups)
6
6
  require "enju_manifestation_viewer"
7
- require "enju_leaf"
8
7
  require "enju_biblio"
9
8
 
10
9
  module Dummy
11
10
  class Application < Rails::Application
12
11
  # Initialize configuration defaults for originally generated Rails version.
13
- config.load_defaults 5.1
12
+ config.load_defaults 5.2
14
13
 
15
14
  # Settings in config/environments/* take precedence over those specified here.
16
15
  # Application configuration should go into files in config/initializers
@@ -1,25 +1,86 @@
1
- # SQLite version 3.x
2
- # gem install sqlite3
1
+ # PostgreSQL. Versions 9.1 and up are supported.
3
2
  #
4
- # Ensure the SQLite 3 gem is defined in your Gemfile
5
- # gem 'sqlite3'
3
+ # Install the pg driver:
4
+ # gem install pg
5
+ # On OS X with Homebrew:
6
+ # gem install pg -- --with-pg-config=/usr/local/bin/pg_config
7
+ # On OS X with MacPorts:
8
+ # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
9
+ # On Windows:
10
+ # gem install pg
11
+ # Choose the win32 build.
12
+ # Install PostgreSQL and put its /bin directory on your path.
13
+ #
14
+ # Configure Using Gemfile
15
+ # gem 'pg'
6
16
  #
7
17
  default: &default
8
- adapter: sqlite3
18
+ adapter: postgresql
19
+ encoding: unicode
20
+ # For details on connection pooling, see Rails configuration guide
21
+ # http://guides.rubyonrails.org/configuring.html#database-pooling
9
22
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
10
- timeout: 5000
23
+ username: postgres
11
24
 
12
25
  development:
13
26
  <<: *default
14
- database: db/development.sqlite3
27
+ database: enju_manifestation_viewer_dummy_development
28
+
29
+ # The specified database role being used to connect to postgres.
30
+ # To create additional roles in postgres see `$ createuser --help`.
31
+ # When left blank, postgres will use the default role. This is
32
+ # the same name as the operating system user that initialized the database.
33
+ #username: enju_manifestation_viewer_dummy
34
+
35
+ # The password associated with the postgres role (username).
36
+ #password:
37
+
38
+ # Connect on a TCP socket. Omitted by default since the client uses a
39
+ # domain socket that doesn't need configuration. Windows does not have
40
+ # domain sockets, so uncomment these lines.
41
+ #host: localhost
42
+
43
+ # The TCP port the server listens on. Defaults to 5432.
44
+ # If your server runs on a different port number, change accordingly.
45
+ #port: 5432
46
+
47
+ # Schema search path. The server defaults to $user,public
48
+ #schema_search_path: myapp,sharedapp,public
49
+
50
+ # Minimum log levels, in increasing order:
51
+ # debug5, debug4, debug3, debug2, debug1,
52
+ # log, notice, warning, error, fatal, and panic
53
+ # Defaults to warning.
54
+ #min_messages: notice
15
55
 
16
56
  # Warning: The database defined as "test" will be erased and
17
57
  # re-generated from your development database when you run "rake".
18
58
  # Do not set this db to the same as development or production.
19
59
  test:
20
60
  <<: *default
21
- database: db/test.sqlite3
61
+ database: enju_manifestation_viewer_dummy_test
22
62
 
63
+ # As with config/secrets.yml, you never want to store sensitive information,
64
+ # like your database password, in your source code. If your source code is
65
+ # ever seen by anyone, they now have access to your database.
66
+ #
67
+ # Instead, provide the password as a unix environment variable when you boot
68
+ # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
69
+ # for a full rundown on how to provide these environment variables in a
70
+ # production deployment.
71
+ #
72
+ # On Heroku and other platform providers, you may have a full connection URL
73
+ # available as an environment variable. For example:
74
+ #
75
+ # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
76
+ #
77
+ # You can use this database configuration with:
78
+ #
79
+ # production:
80
+ # url: <%= ENV['DATABASE_URL'] %>
81
+ #
23
82
  production:
24
83
  <<: *default
25
- database: db/production.sqlite3
84
+ database: enju_manifestation_viewer_dummy_production
85
+ username: enju_manifestation_viewer_dummy
86
+ password: <%= ENV['DUMMY_DATABASE_PASSWORD'] %>
@@ -12,4 +12,3 @@ Rails.application.config.assets.paths << Rails.root.join('node_modules')
12
12
  # application.js, application.css, and all non-JS/CSS in the app/assets
13
13
  # folder are already added.
14
14
  # Rails.application.config.assets.precompile += %w( admin.js admin.css )
15
- Rails.application.config.assets.precompile += %w( icons/page_white_text.png unknown_resource.png )
@@ -1,12 +1,10 @@
1
1
  class CreateUserHasRoles < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :user_has_roles do |t|
4
- t.integer :user_id
5
- t.integer :role_id
4
+ t.references :user, index: true, foreign_key: true, null: false
5
+ t.references :role, index: true, foreign_key: true, null: false
6
6
 
7
7
  t.timestamps
8
8
  end
9
- add_index :user_has_roles, :user_id
10
- add_index :user_has_roles, :role_id
11
9
  end
12
10
  end
@@ -11,6 +11,6 @@ class AddAdditionalAttributesToUser < ActiveRecord::Migration[4.2]
11
11
  add_column :users, :confirmed_at, :datetime
12
12
 
13
13
  add_index :users, :username, unique: true
14
- add_index :users, :unlock_token, unique: true
14
+ add_index :users, :unlock_token, unique: true
15
15
  end
16
16
  end
@@ -1,20 +1,19 @@
1
1
  class CreateProfiles < ActiveRecord::Migration[4.2]
2
2
  def change
3
3
  create_table :profiles do |t|
4
- t.integer :user_id
5
- t.integer :user_group_id
6
- t.integer :library_id
4
+ t.references :user, index: true, foreign_key: true
5
+ t.references :user_group, index: true
6
+ t.references :library, index: true
7
7
  t.string :locale
8
8
  t.string :user_number
9
9
  t.text :full_name
10
10
  t.text :note
11
11
  t.text :keyword_list
12
- t.integer :required_role_id
12
+ t.references :required_role, index: false
13
13
 
14
14
  t.timestamps
15
15
  end
16
16
 
17
- add_index :profiles, :user_id
18
17
  add_index :profiles, :user_number, unique: true
19
18
  end
20
19
  end
@@ -12,6 +12,6 @@ class CreateUserImportFileTransitions < ActiveRecord::Migration[4.2]
12
12
  t.timestamps
13
13
  end
14
14
 
15
- add_index :user_import_file_transitions, %i[sort_key user_import_file_id], unique: true, name: "index_user_import_file_transitions_on_sort_key_and_file_id"
15
+ add_index :user_import_file_transitions, [:sort_key, :user_import_file_id], unique: true, name: "index_user_import_file_transitions_on_sort_key_and_file_id"
16
16
  end
17
17
  end