enju_seed 0.3.2 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/Rakefile +1 -1
- data/app/controllers/profiles_controller.rb +3 -3
- data/app/controllers/roles_controller.rb +1 -1
- data/app/models/concerns/enju_seed/enju_user.rb +7 -7
- data/app/models/identity.rb +1 -1
- data/app/models/profile.rb +2 -2
- data/app/models/role.rb +2 -2
- data/app/models/user_has_role.rb +1 -4
- data/app/views/roles/_form.html.erb +1 -1
- data/app/views/roles/show.html.erb +0 -5
- data/lib/enju_seed/version.rb +1 -1
- data/lib/generators/enju_seed/setup/setup_generator.rb +9 -0
- data/lib/generators/enju_seed/setup/templates/db/fixtures/roles.yml +38 -0
- data/lib/tasks/enju_seed_tasks.rake +8 -4
- data/spec/controllers/profiles_controller_spec.rb +8 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/models/user.rb +1 -1
- data/spec/dummy/config/application.rb +1 -1
- data/spec/dummy/config/webpack/development.js +5 -0
- data/spec/dummy/config/webpack/environment.js +11 -0
- data/spec/dummy/config/webpack/production.js +5 -0
- data/spec/dummy/config/webpack/test.js +5 -0
- data/spec/dummy/config/webpacker.yml +95 -0
- data/spec/dummy/db/migrate/20151213070943_add_translation_table_to_library_group.rb +0 -8
- data/spec/dummy/db/migrate/20160319144230_create_issn_records.rb +11 -0
- data/spec/dummy/db/migrate/20160506144040_create_isbn_records.rb +11 -0
- data/spec/dummy/db/migrate/20160801080612_add_most_recent_to_import_request_transitions.rb +9 -0
- data/spec/dummy/db/migrate/20160801080619_add_most_recent_to_resource_import_file_transitions.rb +9 -0
- data/spec/dummy/db/migrate/20160801080637_add_most_recent_to_resource_export_file_transitions.rb +9 -0
- data/spec/dummy/db/migrate/20160801080643_add_most_recent_to_agent_import_file_transitions.rb +9 -0
- data/spec/dummy/db/migrate/20160811102604_add_picture_width_to_picture_file.rb +6 -0
- data/spec/dummy/db/migrate/20160814165332_add_most_recent_to_message_request_transitions.rb +9 -0
- data/spec/dummy/db/migrate/20160820004638_add_attachment_attachment_to_carrier_types.rb +11 -0
- data/spec/dummy/db/migrate/20170116134107_create_issn_record_and_manifestations.rb +11 -0
- data/spec/dummy/db/migrate/20170116134120_create_isbn_record_and_manifestations.rb +11 -0
- data/spec/dummy/db/migrate/20171119051258_set_not_null_to_manifestation_id_on_items.rb +5 -0
- data/spec/dummy/db/migrate/20180107160726_add_constraints_to_most_recent_for_user_import_file_transitions.rb +13 -0
- data/spec/dummy/db/migrate/20180107160740_add_constraints_to_most_recent_for_user_export_file_transitions.rb +13 -0
- data/spec/dummy/db/migrate/20180107161311_add_constraints_to_most_recent_for_agent_import_file_transitions.rb +13 -0
- data/spec/dummy/db/migrate/20180107161331_add_constraints_to_most_recent_for_resource_import_file_transitions.rb +13 -0
- data/spec/dummy/db/migrate/20180107161347_add_constraints_to_most_recent_for_resource_export_file_transitions.rb +13 -0
- data/spec/dummy/db/migrate/20180107161410_add_constraints_to_most_recent_for_import_request_transitions.rb +13 -0
- data/spec/dummy/db/migrate/20180107162659_add_constraints_to_most_recent_for_message_transitions.rb +13 -0
- data/spec/dummy/db/migrate/20180107162711_add_constraints_to_most_recent_for_message_request_transitions.rb +13 -0
- data/spec/dummy/db/migrate/20181026064038_add_login_banner_to_library_group.rb +6 -0
- data/spec/dummy/db/migrate/20181030072731_add_not_null_to_position_on_carrier_type.rb +14 -0
- data/spec/dummy/db/migrate/20181030074920_add_not_null_to_position_on_library.rb +14 -0
- data/spec/dummy/db/migrate/20190208135957_create_active_storage_tables.active_storage.rb +27 -0
- data/spec/dummy/db/migrate/20190311154610_create_periodicals.rb +10 -0
- data/spec/dummy/db/migrate/20190314151124_add_full_name_translations_to_create.rb +7 -0
- data/spec/dummy/db/schema.rb +116 -25
- data/spec/models/user_has_role_spec.rb +0 -1
- data/spec/views/profiles/show.html.erb_spec.rb +1 -1
- data/spec/views/roles/edit.html.erb_spec.rb +18 -0
- data/spec/views/roles/index.html.erb_spec.rb +14 -0
- data/spec/views/roles/new.html.erb_spec.rb +18 -0
- data/spec/views/roles/show.html.erb_spec.rb +14 -0
- metadata +388 -258
- data/README.rdoc +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 954c50f3db39ed75d15e494f3abe93af699556e4981fbf21ea8dad5ea6f8b8b1
|
4
|
+
data.tar.gz: 35991b1a992c6b70e0726dcaa35faf211faa75c997f51717d8260a9c706ef41f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 202247de7ec8a79ba7cb7a5844b7d6d25668a7cdb4f40af97c740bf6d6c2068262e06791c4317d07fdc733568bd53a539be6137ec73e7c3f45c17c106a3cda32
|
7
|
+
data.tar.gz: cb12be922423784e642770a0ddbdbeabfbfa78d78bb9aee8d640c9768a4400b1ad67a91faac531cf4b0caecf77c6b6bb20ff2f04abc92ca2d5cd2e47e24ab78a
|
data/README.md
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# EnjuSeed
|
2
|
+
[![Travis CI](https://travis-ci.com/next-l/enju_seed.svg?branch=1.3)](https://travis-ci.com/next-l/enju_seed)
|
3
|
+
[![Coverage Status](https://coveralls.io/repos/github/next-l/enju_seed/badge.svg?branch=1.3)](https://coveralls.io/github/next-l/enju_seed?branch=1.3)
|
4
|
+
[![security](https://hakiri.io/github/next-l/enju_seed/1.3.svg)](https://hakiri.io/github/next-l/enju_seed/1.3)
|
5
|
+
|
6
|
+
This project rocks and uses MIT-LICENSE.
|
7
|
+
|
8
|
+
## 製作者・貢献者 (Authors and contributors)
|
9
|
+
* [TANABE, Kosuke](https://github.com/nabeta) ([@nabeta](https://twitter.com/nabeta))
|
10
|
+
* [Project Next-L](https://www.next-l.jp) ([@ProjectNextL](https://twitter.com/ProjectNextL))
|
data/Rakefile
CHANGED
@@ -8,7 +8,7 @@ class ProfilesController < ApplicationController
|
|
8
8
|
# GET /profiles.json
|
9
9
|
def index
|
10
10
|
if params[:username].present?
|
11
|
-
profile = User.
|
11
|
+
profile = User.find_by(username: params[:username]).try(:profile)
|
12
12
|
if profile
|
13
13
|
redirect_to profile
|
14
14
|
return
|
@@ -116,7 +116,7 @@ class ProfilesController < ApplicationController
|
|
116
116
|
respond_to do |format|
|
117
117
|
if @profile.save
|
118
118
|
if @profile.user
|
119
|
-
@profile.user.role = Role.
|
119
|
+
@profile.user.role = Role.find_by(name: 'User')
|
120
120
|
flash[:temporary_password] = password
|
121
121
|
end
|
122
122
|
format.html { redirect_to @profile, notice: t('controller.successfully_created', model: t('activerecord.models.profile')) }
|
@@ -132,7 +132,7 @@ class ProfilesController < ApplicationController
|
|
132
132
|
# PUT /profiles/1
|
133
133
|
# PUT /profiles/1.json
|
134
134
|
def update
|
135
|
-
@profile.
|
135
|
+
@profile.update(profile_update_params)
|
136
136
|
if @profile.user
|
137
137
|
if @profile.user.auto_generated_password == "1"
|
138
138
|
password = @profile.user.set_auto_generated_password
|
@@ -35,7 +35,7 @@ class RolesController < ApplicationController
|
|
35
35
|
end
|
36
36
|
|
37
37
|
respond_to do |format|
|
38
|
-
if @role.
|
38
|
+
if @role.update(role_params)
|
39
39
|
format.html { redirect_to @role, notice: t('controller.successfully_updated', model: t('activerecord.models.role')) }
|
40
40
|
format.json { head :no_content }
|
41
41
|
else
|
@@ -57,7 +57,7 @@ module EnjuSeed
|
|
57
57
|
|
58
58
|
# ユーザの情報をエクスポートします。
|
59
59
|
# @param [Hash] options
|
60
|
-
def self.export(options = {format: :
|
60
|
+
def self.export(options = {format: :text})
|
61
61
|
header = %w(
|
62
62
|
username
|
63
63
|
full_name
|
@@ -113,7 +113,7 @@ module EnjuSeed
|
|
113
113
|
end
|
114
114
|
lines << line
|
115
115
|
}
|
116
|
-
if options[:format] == :
|
116
|
+
if options[:format] == :text
|
117
117
|
lines.map{|line| line.to_csv(col_sep: "\t")}.unshift(header.to_csv(col_sep: "\t")).join
|
118
118
|
else
|
119
119
|
lines
|
@@ -147,9 +147,9 @@ module EnjuSeed
|
|
147
147
|
|
148
148
|
# ユーザに使用不可の設定を反映させます。
|
149
149
|
def set_lock_information
|
150
|
-
if locked == '1' and
|
150
|
+
if locked == '1' and active_for_authentication?
|
151
151
|
lock_access!
|
152
|
-
elsif locked == '0' and !
|
152
|
+
elsif locked == '0' and !active_for_authentication?
|
153
153
|
unlock_access!
|
154
154
|
end
|
155
155
|
end
|
@@ -176,7 +176,7 @@ module EnjuSeed
|
|
176
176
|
# @return [Object]
|
177
177
|
def check_role_before_destroy
|
178
178
|
if has_role?('Administrator')
|
179
|
-
if Role.
|
179
|
+
if Role.find_by(name: 'Administrator').users.count == 1
|
180
180
|
raise username + 'This is the last administrator in this system.'
|
181
181
|
end
|
182
182
|
end
|
@@ -209,7 +209,7 @@ module EnjuSeed
|
|
209
209
|
# @return [Boolean]
|
210
210
|
def last_librarian?
|
211
211
|
if has_role?('Librarian')
|
212
|
-
role = Role.
|
212
|
+
role = Role.find_by(name: 'Librarian')
|
213
213
|
return true if role.users.count == 1
|
214
214
|
false
|
215
215
|
end
|
@@ -244,7 +244,7 @@ module EnjuSeed
|
|
244
244
|
|
245
245
|
# 最後の管理者を削除しようとした
|
246
246
|
if has_role?('Administrator')
|
247
|
-
if Role.
|
247
|
+
if Role.find_by(name: 'Administrator').users.count == 1
|
248
248
|
errors[:base] << I18n.t('user.last_administrator')
|
249
249
|
end
|
250
250
|
end
|
data/app/models/identity.rb
CHANGED
data/app/models/profile.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class Profile <
|
1
|
+
class Profile < ApplicationRecord
|
2
2
|
scope :administrators, -> { joins(user: :role).where('roles.name = ?', 'Administrator') }
|
3
3
|
scope :librarians, -> { joins(user: :role).where('roles.name = ? OR roles.name = ?', 'Administrator', 'Librarian') }
|
4
4
|
belongs_to :user, dependent: :destroy, optional: true
|
@@ -50,7 +50,7 @@ class Profile < ActiveRecord::Base
|
|
50
50
|
# 既定のユーザ権限を設定します。
|
51
51
|
# @return [void]
|
52
52
|
def set_role_and_agent
|
53
|
-
self.required_role = Role.
|
53
|
+
self.required_role = Role.find_by(name: 'Librarian') unless required_role
|
54
54
|
self.locale = I18n.default_locale.to_s unless locale
|
55
55
|
end
|
56
56
|
|
data/app/models/role.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class Role <
|
1
|
+
class Role < ApplicationRecord
|
2
2
|
include MasterModel
|
3
3
|
validates :name, presence: true, format: { with: /\A[A-Za-z][a-z_,]*[a-z]\z/ }
|
4
4
|
has_many :user_has_roles
|
@@ -26,7 +26,7 @@ class Role < ActiveRecord::Base
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def self.default_role
|
29
|
-
Role.
|
29
|
+
Role.find_by(name: 'Guest')
|
30
30
|
end
|
31
31
|
|
32
32
|
private
|
data/app/models/user_has_role.rb
CHANGED
@@ -1,10 +1,7 @@
|
|
1
|
-
class UserHasRole <
|
1
|
+
class UserHasRole < ApplicationRecord
|
2
2
|
belongs_to :user
|
3
3
|
belongs_to :role
|
4
4
|
accepts_nested_attributes_for :role
|
5
|
-
|
6
|
-
# validates_uniqueness_of :role_id, scope: :user_id
|
7
|
-
# validates_presence_of :role_id, :user_id
|
8
5
|
end
|
9
6
|
|
10
7
|
# == Schema Information
|
@@ -13,11 +13,6 @@
|
|
13
13
|
<%= @role.display_name.localize -%>
|
14
14
|
</p>
|
15
15
|
|
16
|
-
<p>
|
17
|
-
<strong><%= t('activerecord.attributes.role.score') -%>:</strong>
|
18
|
-
<%= @role.score -%>
|
19
|
-
</p>
|
20
|
-
|
21
16
|
<p>
|
22
17
|
<strong><%= t('activerecord.attributes.role.note') -%>:</strong>
|
23
18
|
<%= @role.note -%>
|
data/lib/enju_seed/version.rb
CHANGED
@@ -0,0 +1,9 @@
|
|
1
|
+
class EnjuSeed::SetupGenerator < Rails::Generators::Base
|
2
|
+
source_root File.expand_path('../templates', __FILE__)
|
3
|
+
desc "Create a setup file for Next-L Enju"
|
4
|
+
|
5
|
+
def copy_setup_files
|
6
|
+
directory("db/fixtures", "db/fixtures/enju_seed")
|
7
|
+
rake("enju_seed_engine:install:migrations")
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
---
|
2
|
+
role_00001:
|
3
|
+
name: Guest
|
4
|
+
display_name: Guest
|
5
|
+
id: 1
|
6
|
+
note:
|
7
|
+
position: 1
|
8
|
+
role_00002:
|
9
|
+
name: User
|
10
|
+
display_name: User
|
11
|
+
id: 2
|
12
|
+
note:
|
13
|
+
position: 2
|
14
|
+
role_00003:
|
15
|
+
name: Librarian
|
16
|
+
display_name: Librarian
|
17
|
+
id: 3
|
18
|
+
note:
|
19
|
+
position: 3
|
20
|
+
role_00004:
|
21
|
+
name: Administrator
|
22
|
+
display_name: Administrator
|
23
|
+
id: 4
|
24
|
+
note:
|
25
|
+
position: 4
|
26
|
+
|
27
|
+
# == Schema Information
|
28
|
+
#
|
29
|
+
# Table name: roles
|
30
|
+
#
|
31
|
+
# id :bigint(8) not null, primary key
|
32
|
+
# name :string not null
|
33
|
+
# display_name_translations :jsonb not null
|
34
|
+
# note :text
|
35
|
+
# position :integer
|
36
|
+
# created_at :datetime not null
|
37
|
+
# updated_at :datetime not null
|
38
|
+
#
|
@@ -1,4 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
namespace :enju_seed do
|
2
|
+
desc "create initial records for enju_seed"
|
3
|
+
task setup: :environment do
|
4
|
+
Dir.glob(Rails.root.to_s + '/db/fixtures/enju_seed/*.yml').each do |file|
|
5
|
+
ActiveRecord::FixtureSet.create_fixtures('db/fixtures/enju_seed', File.basename(file, '.*'))
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
@@ -418,6 +418,14 @@ describe ProfilesController do
|
|
418
418
|
assigns(:profile).user.locked_at.should be_truthy
|
419
419
|
assigns(:profile).user.access_locked?.should be_truthy
|
420
420
|
end
|
421
|
+
|
422
|
+
it "should unlock other user" do
|
423
|
+
profiles(:user1).user.lock_access!
|
424
|
+
put :update, params: { id: profiles(:user1).id, profile: { user_attributes: { id: 3, locked: '0', username: 'user1' } } }
|
425
|
+
response.should redirect_to profile_url(assigns(:profile))
|
426
|
+
expect(assigns(:profile).user.locked_at).to be_falsy
|
427
|
+
expect(assigns(:profile).user.access_locked?).to be_falsy
|
428
|
+
end
|
421
429
|
end
|
422
430
|
|
423
431
|
describe "When logged in as User" do
|
@@ -9,7 +9,7 @@ require "enju_leaf"
|
|
9
9
|
module Dummy
|
10
10
|
class Application < Rails::Application
|
11
11
|
# Initialize configuration defaults for originally generated Rails version.
|
12
|
-
config.load_defaults 5.
|
12
|
+
config.load_defaults 5.2
|
13
13
|
|
14
14
|
# Settings in config/environments/* take precedence over those specified here.
|
15
15
|
# Application configuration should go into files in config/initializers
|
@@ -0,0 +1,95 @@
|
|
1
|
+
# Note: You must restart bin/webpack-dev-server for changes to take effect
|
2
|
+
|
3
|
+
default: &default
|
4
|
+
source_path: app/javascript
|
5
|
+
source_entry_path: packs
|
6
|
+
public_root_path: public
|
7
|
+
public_output_path: packs
|
8
|
+
cache_path: tmp/cache/webpacker
|
9
|
+
check_yarn_integrity: false
|
10
|
+
webpack_compile_output: false
|
11
|
+
|
12
|
+
# Additional paths webpack should lookup modules
|
13
|
+
# ['app/assets', 'engine/foo/app/assets']
|
14
|
+
resolved_paths: []
|
15
|
+
|
16
|
+
# Reload manifest.json on all requests so we reload latest compiled packs
|
17
|
+
cache_manifest: false
|
18
|
+
|
19
|
+
# Extract and emit a css file
|
20
|
+
extract_css: false
|
21
|
+
|
22
|
+
static_assets_extensions:
|
23
|
+
- .jpg
|
24
|
+
- .jpeg
|
25
|
+
- .png
|
26
|
+
- .gif
|
27
|
+
- .tiff
|
28
|
+
- .ico
|
29
|
+
- .svg
|
30
|
+
- .eot
|
31
|
+
- .otf
|
32
|
+
- .ttf
|
33
|
+
- .woff
|
34
|
+
- .woff2
|
35
|
+
|
36
|
+
extensions:
|
37
|
+
- .mjs
|
38
|
+
- .js
|
39
|
+
- .sass
|
40
|
+
- .scss
|
41
|
+
- .css
|
42
|
+
- .module.sass
|
43
|
+
- .module.scss
|
44
|
+
- .module.css
|
45
|
+
- .png
|
46
|
+
- .svg
|
47
|
+
- .gif
|
48
|
+
- .jpeg
|
49
|
+
- .jpg
|
50
|
+
|
51
|
+
development:
|
52
|
+
<<: *default
|
53
|
+
compile: true
|
54
|
+
|
55
|
+
# Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules
|
56
|
+
check_yarn_integrity: true
|
57
|
+
|
58
|
+
# Reference: https://webpack.js.org/configuration/dev-server/
|
59
|
+
dev_server:
|
60
|
+
https: false
|
61
|
+
host: localhost
|
62
|
+
port: 3035
|
63
|
+
public: localhost:3035
|
64
|
+
hmr: false
|
65
|
+
# Inline should be set to true if using HMR
|
66
|
+
inline: true
|
67
|
+
overlay: true
|
68
|
+
compress: true
|
69
|
+
disable_host_check: true
|
70
|
+
use_local_ip: false
|
71
|
+
quiet: false
|
72
|
+
headers:
|
73
|
+
'Access-Control-Allow-Origin': '*'
|
74
|
+
watch_options:
|
75
|
+
ignored: '**/node_modules/**'
|
76
|
+
|
77
|
+
|
78
|
+
test:
|
79
|
+
<<: *default
|
80
|
+
compile: true
|
81
|
+
|
82
|
+
# Compile test packs to a separate directory
|
83
|
+
public_output_path: packs-test
|
84
|
+
|
85
|
+
production:
|
86
|
+
<<: *default
|
87
|
+
|
88
|
+
# Production depends on precompilation of packs prior to booting for performance.
|
89
|
+
compile: false
|
90
|
+
|
91
|
+
# Extract and emit a css file
|
92
|
+
extract_css: true
|
93
|
+
|
94
|
+
# Cache manifest.json for performance
|
95
|
+
cache_manifest: true
|
@@ -8,19 +8,11 @@ class AddTranslationTableToLibraryGroup < ActiveRecord::Migration[4.2]
|
|
8
8
|
migrate_data: true
|
9
9
|
})
|
10
10
|
end
|
11
|
-
|
12
|
-
if defined?(AwesomeHstoreTranslate)
|
13
|
-
add_column :library_groups, :login_banner, :hstore
|
14
|
-
end
|
15
11
|
end
|
16
12
|
|
17
13
|
def down
|
18
14
|
if defined?(Globalize)
|
19
15
|
LibraryGroup.drop_translation_table! migrate_data: true
|
20
16
|
end
|
21
|
-
|
22
|
-
if defined?(AwesomeHstoreTranslate)
|
23
|
-
remove_column :library_groups, :login_banner
|
24
|
-
end
|
25
17
|
end
|
26
18
|
end
|
data/spec/dummy/db/migrate/20160801080619_add_most_recent_to_resource_import_file_transitions.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
class AddMostRecentToResourceImportFileTransitions < ActiveRecord::Migration[4.2]
|
2
|
+
def up
|
3
|
+
add_column :resource_import_file_transitions, :most_recent, :boolean, null: true
|
4
|
+
end
|
5
|
+
|
6
|
+
def down
|
7
|
+
remove_column :resource_import_file_transitions, :most_recent
|
8
|
+
end
|
9
|
+
end
|
data/spec/dummy/db/migrate/20160801080637_add_most_recent_to_resource_export_file_transitions.rb
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
class AddMostRecentToResourceExportFileTransitions < ActiveRecord::Migration[4.2]
|
2
|
+
def up
|
3
|
+
add_column :resource_export_file_transitions, :most_recent, :boolean, null: true
|
4
|
+
end
|
5
|
+
|
6
|
+
def down
|
7
|
+
remove_column :resource_export_file_transitions, :most_recent
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class CreateIssnRecordAndManifestations < ActiveRecord::Migration[5.2]
|
2
|
+
def change
|
3
|
+
create_table :issn_record_and_manifestations do |t|
|
4
|
+
t.references :issn_record, foreign_key: true, on_delete: :cascade, null: false
|
5
|
+
t.references :manifestation, foreign_key: true, on_delete: :cascade, null: false
|
6
|
+
t.integer :position
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class CreateIsbnRecordAndManifestations < ActiveRecord::Migration[5.2]
|
2
|
+
def change
|
3
|
+
create_table :isbn_record_and_manifestations do |t|
|
4
|
+
t.references :isbn_record, foreign_key: true, on_delete: :cascade, null: false
|
5
|
+
t.references :manifestation, foreign_key: true, null: false, on_delete: :cascade
|
6
|
+
t.integer :position
|
7
|
+
|
8
|
+
t.timestamps
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class AddConstraintsToMostRecentForUserImportFileTransitions < ActiveRecord::Migration[4.2]
|
2
|
+
disable_ddl_transaction!
|
3
|
+
|
4
|
+
def up
|
5
|
+
add_index :user_import_file_transitions, [:user_import_file_id, :most_recent], unique: true, where: "most_recent", name: "index_user_import_file_transitions_parent_most_recent" #, algorithm: :concurrently
|
6
|
+
change_column_null :user_import_file_transitions, :most_recent, false
|
7
|
+
end
|
8
|
+
|
9
|
+
def down
|
10
|
+
remove_index :user_import_file_transitions, name: "index_user_import_file_transitions_parent_most_recent"
|
11
|
+
change_column_null :user_import_file_transitions, :most_recent, true
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class AddConstraintsToMostRecentForUserExportFileTransitions < ActiveRecord::Migration[4.2]
|
2
|
+
disable_ddl_transaction!
|
3
|
+
|
4
|
+
def up
|
5
|
+
add_index :user_export_file_transitions, [:user_export_file_id, :most_recent], unique: true, where: "most_recent", name: "index_user_export_file_transitions_parent_most_recent" #, algorithm: :concurrently
|
6
|
+
change_column_null :user_export_file_transitions, :most_recent, false
|
7
|
+
end
|
8
|
+
|
9
|
+
def down
|
10
|
+
remove_index :user_export_file_transitions, name: "index_user_export_file_transitions_parent_most_recent"
|
11
|
+
change_column_null :user_export_file_transitions, :most_recent, true
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class AddConstraintsToMostRecentForAgentImportFileTransitions < ActiveRecord::Migration[4.2]
|
2
|
+
disable_ddl_transaction!
|
3
|
+
|
4
|
+
def up
|
5
|
+
add_index :agent_import_file_transitions, [:agent_import_file_id, :most_recent], unique: true, where: "most_recent", name: "index_agent_import_file_transitions_parent_most_recent" #, algorithm: :concurrently
|
6
|
+
change_column_null :agent_import_file_transitions, :most_recent, false
|
7
|
+
end
|
8
|
+
|
9
|
+
def down
|
10
|
+
remove_index :agent_import_file_transitions, name: "index_agent_import_file_transitions_parent_most_recent"
|
11
|
+
change_column_null :agent_import_file_transitions, :most_recent, true
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class AddConstraintsToMostRecentForResourceImportFileTransitions < ActiveRecord::Migration[4.2]
|
2
|
+
disable_ddl_transaction!
|
3
|
+
|
4
|
+
def up
|
5
|
+
add_index :resource_import_file_transitions, [:resource_import_file_id, :most_recent], unique: true, where: "most_recent", name: "index_resource_import_file_transitions_parent_most_recent" #, algorithm: :concurrently
|
6
|
+
change_column_null :resource_import_file_transitions, :most_recent, false
|
7
|
+
end
|
8
|
+
|
9
|
+
def down
|
10
|
+
remove_index :resource_import_file_transitions, name: "index_resource_import_file_transitions_parent_most_recent"
|
11
|
+
change_column_null :resource_import_file_transitions, :most_recent, true
|
12
|
+
end
|
13
|
+
end
|