enju_seed 0.3.0.beta.2 → 0.3.0.beta.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/my_accounts_controller.rb +4 -4
  3. data/app/models/concerns/enju_seed/enju_user.rb +1 -1
  4. data/app/models/concerns/master_model.rb +1 -11
  5. data/app/models/identity.rb +1 -1
  6. data/app/models/profile.rb +6 -8
  7. data/app/models/role.rb +10 -27
  8. data/app/models/user_has_role.rb +2 -2
  9. data/app/policies/user_export_file_policy.rb +21 -0
  10. data/app/policies/user_import_file_policy.rb +21 -0
  11. data/app/policies/user_import_result_policy.rb +21 -0
  12. data/app/views/my_accounts/_edit_credential.html.slim +6 -6
  13. data/app/views/my_accounts/show.html.slim +1 -1
  14. data/app/views/profiles/_edit_credential.html.erb +6 -6
  15. data/app/views/profiles/_edit_credential.html.slim +6 -6
  16. data/app/views/profiles/new.html.slim +3 -3
  17. data/app/views/roles/index.html.slim +1 -1
  18. data/app/views/roles/show.html.slim +1 -1
  19. data/db/migrate/041_create_roles.rb +5 -6
  20. data/db/migrate/20100606065209_create_user_has_roles.rb +3 -3
  21. data/db/migrate/20140122054321_create_profiles.rb +5 -13
  22. data/db/migrate/20140811031145_add_expired_at_to_profile.rb +1 -1
  23. data/db/migrate/20141003181336_add_full_name_transcription_to_profile.rb +1 -1
  24. data/db/migrate/20141003182825_add_date_of_birth_to_profile.rb +1 -1
  25. data/db/migrate/20150421023923_create_identities.rb +4 -6
  26. data/db/migrate/20151126005552_add_provider_to_identity.rb +2 -2
  27. data/db/migrate/20170114174536_add_profile_id_to_user.rb +5 -0
  28. data/lib/enju_seed/engine.rb +2 -0
  29. data/lib/enju_seed/version.rb +1 -1
  30. data/spec/controllers/my_accounts_controller_spec.rb +0 -12
  31. data/spec/controllers/profiles_controller_spec.rb +24 -21
  32. data/spec/controllers/roles_controller_spec.rb +1 -1
  33. data/spec/dummy/db/migrate/005_create_manifestations.rb +12 -13
  34. data/spec/dummy/db/migrate/006_create_items.rb +7 -8
  35. data/spec/dummy/db/migrate/012_create_owns.rb +3 -5
  36. data/spec/dummy/db/migrate/015_create_creates.rb +3 -5
  37. data/spec/dummy/db/migrate/047_create_produces.rb +3 -5
  38. data/spec/dummy/db/migrate/059_create_libraries.rb +9 -10
  39. data/spec/dummy/db/migrate/069_create_shelves.rb +5 -6
  40. data/spec/dummy/db/migrate/073_create_carrier_types.rb +3 -3
  41. data/spec/dummy/db/migrate/077_create_user_groups.rb +4 -4
  42. data/spec/dummy/db/migrate/080_create_library_groups.rb +6 -7
  43. data/spec/dummy/db/migrate/112_create_frequencies.rb +3 -3
  44. data/spec/dummy/db/migrate/117_create_form_of_works.rb +3 -3
  45. data/spec/dummy/db/migrate/120_create_baskets.rb +3 -4
  46. data/spec/dummy/db/migrate/124_create_bookstores.rb +3 -3
  47. data/spec/dummy/db/migrate/130_create_request_status_types.rb +3 -3
  48. data/spec/dummy/db/migrate/131_create_request_types.rb +3 -3
  49. data/spec/dummy/db/migrate/20080830154109_create_realizes.rb +3 -5
  50. data/spec/dummy/db/migrate/20080830172106_create_exemplifies.rb +2 -4
  51. data/spec/dummy/db/migrate/20081006090811_create_subscriptions.rb +4 -5
  52. data/spec/dummy/db/migrate/20081006093246_create_subscribes.rb +5 -7
  53. data/spec/dummy/db/migrate/20090720091106_create_medium_of_performances.rb +3 -3
  54. data/spec/dummy/db/migrate/20090720091429_create_content_types.rb +3 -3
  55. data/spec/dummy/db/migrate/20100129142347_create_import_requests.rb +4 -7
  56. data/spec/dummy/db/migrate/20100211105551_add_admin_networks_to_library_group.rb +1 -1
  57. data/spec/dummy/db/migrate/20100525124311_create_manifestation_relationships.rb +4 -6
  58. data/spec/dummy/db/migrate/20120319173203_create_accepts.rb +3 -6
  59. data/spec/dummy/db/migrate/20130506175834_create_identifiers.rb +4 -5
  60. data/spec/dummy/db/migrate/20140110122216_create_user_import_files.rb +2 -2
  61. data/spec/dummy/db/migrate/20140110131010_create_user_import_results.rb +2 -2
  62. data/spec/dummy/db/migrate/20140524074813_create_user_import_file_transitions.rb +5 -4
  63. data/spec/dummy/db/migrate/20140529014410_create_item_transitions.rb +15 -0
  64. data/spec/dummy/db/migrate/20140709113413_create_user_export_files.rb +1 -1
  65. data/spec/dummy/db/migrate/20140709113905_create_user_export_file_transitions.rb +5 -5
  66. data/spec/dummy/db/migrate/20140720170714_add_default_library_id_to_user_import_file.rb +1 -1
  67. data/spec/dummy/db/migrate/20140720170735_add_default_user_group_id_to_user_import_file.rb +1 -1
  68. data/spec/dummy/db/migrate/20140802082007_add_manifestation_id_to_item.rb +2 -3
  69. data/spec/dummy/db/migrate/20141029131633_create_periodicals.rb +2 -2
  70. data/spec/dummy/db/migrate/20150924115059_create_withdraws.rb +3 -5
  71. data/spec/dummy/db/migrate/20151213072705_add_footer_banner_to_library_group.rb +2 -2
  72. data/spec/dummy/db/migrate/20151216123621_create_doi_records.rb +4 -4
  73. data/spec/dummy/db/migrate/20160319144230_create_issn_records.rb +4 -4
  74. data/spec/dummy/db/migrate/20160506144040_create_isbn_records.rb +4 -4
  75. data/spec/dummy/db/schema.rb +173 -144
  76. data/spec/factories/profile.rb +4 -4
  77. data/spec/factories/user.rb +3 -0
  78. data/spec/fixtures/libraries.yml +37 -37
  79. data/spec/fixtures/library_groups.yml +27 -20
  80. data/spec/fixtures/profiles.yml +27 -35
  81. data/spec/fixtures/roles.yml +12 -12
  82. data/spec/fixtures/user_groups.yml +20 -10
  83. data/spec/fixtures/user_has_roles.yml +2 -2
  84. data/spec/fixtures/users.yml +7 -0
  85. data/spec/models/profile_spec.rb +7 -9
  86. data/spec/models/role_spec.rb +10 -11
  87. data/spec/models/user_has_role_spec.rb +3 -4
  88. data/spec/models/user_spec.rb +0 -1
  89. metadata +33 -20
  90. data/db/migrate/20140610123439_drop_email_unique_constraint_enju_leaf_rc10.rb +0 -11
  91. data/spec/dummy/db/migrate/20150117111136_add_foreign_key_to_items_referencing_manifestations.rb +0 -5
  92. data/spec/dummy/db/migrate/20150124152756_add_foreign_key_to_shelves_referencing_libraries.rb +0 -6
  93. data/spec/dummy/db/migrate/20160703190209_add_foreign_key_on_manifestation_id_to_reserve.rb +0 -5
@@ -1,4 +1,4 @@
1
- class AddExpiredAtToProfile < ActiveRecord::Migration
1
+ class AddExpiredAtToProfile < ActiveRecord::Migration[5.0]
2
2
  def change
3
3
  add_column :profiles, :expired_at, :datetime
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddFullNameTranscriptionToProfile < ActiveRecord::Migration
1
+ class AddFullNameTranscriptionToProfile < ActiveRecord::Migration[5.0]
2
2
  def change
3
3
  add_column :profiles, :full_name_transcription, :text
4
4
  end
@@ -1,4 +1,4 @@
1
- class AddDateOfBirthToProfile < ActiveRecord::Migration
1
+ class AddDateOfBirthToProfile < ActiveRecord::Migration[5.0]
2
2
  def change
3
3
  add_column :profiles, :date_of_birth, :datetime
4
4
  end
@@ -1,14 +1,12 @@
1
- class CreateIdentities < ActiveRecord::Migration
1
+ class CreateIdentities < ActiveRecord::Migration[5.0]
2
2
  def change
3
3
  create_table :identities do |t|
4
- t.string :name
5
- t.string :email
4
+ t.string :name, index: true
5
+ t.string :email, index: true
6
6
  t.string :password_digest
7
7
  t.references :profile, index: true
8
8
 
9
- t.timestamps null: false
9
+ t.timestamps
10
10
  end
11
- add_index :identities, :name
12
- add_index :identities, :email
13
11
  end
14
12
  end
@@ -1,5 +1,5 @@
1
- class AddProviderToIdentity < ActiveRecord::Migration
1
+ class AddProviderToIdentity < ActiveRecord::Migration[5.0]
2
2
  def change
3
- add_column :identities, :provider, :string
3
+ add_column :identities, :provider, :string, null: false
4
4
  end
5
5
  end
@@ -0,0 +1,5 @@
1
+ class AddProfileIdToUser < ActiveRecord::Migration[5.0]
2
+ def change
3
+ add_reference :users, :profile, foreign_key: {on_delete: :cascade}, type: :uuid
4
+ end
5
+ end
@@ -14,6 +14,8 @@ require 'browser'
14
14
  require 'simple_form'
15
15
  require 'validates_timeliness'
16
16
  require 'shrine'
17
+ require 'json_translate'
18
+ require 'statesman'
17
19
 
18
20
  module EnjuSeed
19
21
  class Engine < ::Rails::Engine
@@ -1,3 +1,3 @@
1
1
  module EnjuSeed
2
- VERSION = '0.3.0.beta.2'.freeze
2
+ VERSION = '0.3.0.beta.3'.freeze
3
3
  end
@@ -27,9 +27,7 @@ describe MyAccountsController do
27
27
  describe 'GET edit' do
28
28
  describe 'When logged in as Administrator' do
29
29
  before(:each) do
30
- profile = FactoryGirl.create(:profile)
31
30
  @user = FactoryGirl.create(:admin)
32
- @user.profile = profile
33
31
  sign_in @user
34
32
  end
35
33
 
@@ -41,9 +39,7 @@ describe MyAccountsController do
41
39
 
42
40
  describe 'When logged in as Librarian' do
43
41
  before(:each) do
44
- profile = FactoryGirl.create(:profile)
45
42
  @user = FactoryGirl.create(:librarian)
46
- @user.profile = profile
47
43
  sign_in @user
48
44
  end
49
45
 
@@ -55,9 +51,7 @@ describe MyAccountsController do
55
51
 
56
52
  describe 'When logged in as User' do
57
53
  before(:each) do
58
- profile = FactoryGirl.create(:profile)
59
54
  @user = FactoryGirl.create(:user)
60
- @user.profile = profile
61
55
  sign_in @user
62
56
  end
63
57
 
@@ -86,9 +80,7 @@ describe MyAccountsController do
86
80
 
87
81
  describe 'When logged in as Administrator' do
88
82
  before(:each) do
89
- profile = FactoryGirl.create(:profile)
90
83
  @user = FactoryGirl.create(:admin, password: 'password', password_confirmation: 'password')
91
- @user.profile = profile
92
84
  sign_in @user
93
85
  end
94
86
 
@@ -134,9 +126,7 @@ describe MyAccountsController do
134
126
 
135
127
  describe 'When logged in as Librarian' do
136
128
  before(:each) do
137
- profile = FactoryGirl.create(:profile)
138
129
  @user = FactoryGirl.create(:librarian, password: 'password', password_confirmation: 'password')
139
- @user.profile = profile
140
130
  sign_in @user
141
131
  end
142
132
 
@@ -177,9 +167,7 @@ describe MyAccountsController do
177
167
 
178
168
  describe 'When logged in as User' do
179
169
  before(:each) do
180
- profile = FactoryGirl.create(:profile)
181
170
  @user = FactoryGirl.create(:user, password: 'password', password_confirmation: 'password')
182
- @user.profile = profile
183
171
  sign_in @user
184
172
  end
185
173
 
@@ -314,7 +314,7 @@ describe ProfilesController do
314
314
  describe 'PUT update' do
315
315
  before(:each) do
316
316
  @profile = profiles(:user1)
317
- @attrs = { user_group_id: '3', locale: 'en' }
317
+ @attrs = { user_group_id: user_groups(:user_group_00003).id, locale: 'en' }
318
318
  @invalid_attrs = { user_group_id: '', user_number: '日本語' }
319
319
  end
320
320
 
@@ -391,23 +391,23 @@ describe ProfilesController do
391
391
  end
392
392
 
393
393
  it 'should update other user' do
394
- put :update, params: { id: profiles(:user1).id, profile: { user_number: '00003', locale: 'en', user_group_id: 3, library_id: 3, note: 'test' } }
394
+ put :update, params: { id: profiles(:user1).id, profile: { user_number: '00003', locale: 'en', user_group_id: user_groups(:user_group_00003).id, library_id: libraries(:library_00003).id, note: 'test' } }
395
395
  response.should redirect_to profile_url(assigns(:profile))
396
396
  end
397
397
 
398
398
  it 'should not update other admin' do
399
- put :update, params: { id: profiles(:admin).id, profile: { user_number: '00003', locale: 'en', user_group_id: 3, library_id: 3, note: 'test' } }
399
+ put :update, params: { id: profiles(:admin).id, profile: { user_number: '00003', locale: 'en', user_group_id: user_groups(:user_group_00003).id, library_id: libraries(:library_00003).id, note: 'test' } }
400
400
  response.should be_forbidden
401
401
  end
402
402
 
403
403
  it "should update other user's user_group" do
404
- put :update, params: { id: profiles(:user1).id, profile: { user_group_id: 3, library_id: 3, locale: 'en' } }
404
+ put :update, params: { id: profiles(:user1).id, profile: { user_group_id: user_groups(:user_group_00003).id, library_id: libraries(:library_00003).id, locale: 'en' } }
405
405
  response.should redirect_to profile_url(assigns(:profile))
406
- assigns(:profile).user_group_id.should eq 3
406
+ assigns(:profile).user_group_id.should eq user_groups(:user_group_00003).id
407
407
  end
408
408
 
409
409
  it "should update other user's note" do
410
- put :update, params: { id: profiles(:user1).id, profile: { user_group_id: 3, library_id: 3, note: 'test', locale: 'en' } }
410
+ put :update, params: { id: profiles(:user1).id, profile: { user_group_id: user_groups(:user_group_00003).id, library_id: libraries(:library_00003).id, note: 'test', locale: 'en' } }
411
411
  response.should redirect_to profile_url(assigns(:profile))
412
412
  assert_equal assigns(:profile).note, 'test'
413
413
  end
@@ -457,13 +457,13 @@ describe ProfilesController do
457
457
  end
458
458
 
459
459
  it 'should not update my user_group' do
460
- put :update, params: { id: profiles(:user1).id, profile: { user_group_id: 3, library_id: 3 } }
460
+ put :update, params: { id: profiles(:user1).id, profile: { user_group_id: user_groups(:user_group_00003).id, library_id: libraries(:library_00003).id } }
461
461
  response.should redirect_to profile_url(assigns(:profile))
462
- assigns(:profile).user_group_id.should eq 1
462
+ assigns(:profile).user_group_id.should eq user_groups(:user_group_00001).id
463
463
  end
464
464
 
465
465
  it 'should not update my note' do
466
- put :update, params: { id: profiles(:user1).id, profile: { user_group_id: 3, library_id: 3, note: 'test' } }
466
+ put :update, params: { id: profiles(:user1).id, profile: { user_group_id: user_groups(:user_group_00003).id, library_id: libraries(:library_00003).id, note: 'test' } }
467
467
  response.should redirect_to profile_url(assigns(:profile))
468
468
  assigns(:profile).note.should be_nil
469
469
  end
@@ -504,20 +504,24 @@ describe ProfilesController do
504
504
  end
505
505
 
506
506
  describe 'DELETE destroy' do
507
+ before(:each) do
508
+ @profile = FactoryGirl.create(:profile)
509
+ end
510
+
507
511
  describe 'When logged in as Administrator' do
508
512
  login_fixture_admin
509
513
 
510
514
  it 'destroys the requested user' do
511
- delete :destroy, params: { id: profiles(:user2).id }
515
+ delete :destroy, params: { id: @profile.id }
512
516
  end
513
517
 
514
518
  it 'redirects to the profiles list' do
515
- delete :destroy, params: { id: profiles(:user2).id }
519
+ delete :destroy, params: { id: @profile.id }
516
520
  response.should redirect_to(profiles_url)
517
521
  end
518
522
 
519
523
  it 'should destroy librarian' do
520
- delete :destroy, params: { id: profiles(:librarian2).id }
524
+ delete :destroy, params: { id: FactoryGirl.create(:librarian).profile.id }
521
525
  response.should redirect_to(profiles_url)
522
526
  end
523
527
  end
@@ -526,17 +530,17 @@ describe ProfilesController do
526
530
  login_fixture_librarian
527
531
 
528
532
  it 'destroys the requested user' do
529
- delete :destroy, params: { id: profiles(:user2).id }
533
+ delete :destroy, params: { id: @profile.id }
530
534
  response.should redirect_to(profiles_url)
531
535
  end
532
536
 
533
537
  it 'redirects to the profiles list' do
534
- delete :destroy, params: { id: profiles(:user2).id }
538
+ delete :destroy, params: { id: @profile.id }
535
539
  response.should redirect_to(profiles_url)
536
540
  end
537
541
 
538
542
  it 'should not destroy librarian' do
539
- delete :destroy, params: { id: profiles(:librarian2).id }
543
+ delete :destroy, params: { id: FactoryGirl.create(:librarian_profile).id }
540
544
  response.should be_forbidden
541
545
  end
542
546
 
@@ -551,8 +555,7 @@ describe ProfilesController do
551
555
  end
552
556
 
553
557
  it 'should not be able to delete other librarian user' do
554
- librarian = FactoryGirl.create(:librarian_profile)
555
- delete :destroy, params: { id: librarian.id }
558
+ delete :destroy, params: { id: FactoryGirl.create(:librarian_profile).id }
556
559
  response.should be_forbidden
557
560
  end
558
561
  end
@@ -561,11 +564,11 @@ describe ProfilesController do
561
564
  login_fixture_user
562
565
 
563
566
  it 'destroys the requested user' do
564
- delete :destroy, params: { id: profiles(:user2).id }
567
+ delete :destroy, params: { id: @profile.id }
565
568
  end
566
569
 
567
570
  it 'should be forbidden' do
568
- delete :destroy, params: { id: profiles(:user2).id }
571
+ delete :destroy, params: { id: @profile.id }
569
572
  response.should be_forbidden
570
573
  end
571
574
 
@@ -577,12 +580,12 @@ describe ProfilesController do
577
580
 
578
581
  describe 'When not logged in' do
579
582
  it 'destroys the requested user' do
580
- delete :destroy, params: { id: profiles(:user2).id }
583
+ delete :destroy, params: { id: @profile.id }
581
584
  response.should redirect_to(new_user_session_url)
582
585
  end
583
586
 
584
587
  it 'should be forbidden' do
585
- delete :destroy, params: { id: profiles(:user2).id }
588
+ delete :destroy, params: { id: @profile.id }
586
589
  response.should redirect_to(new_user_session_url)
587
590
  end
588
591
  end
@@ -1,4 +1,4 @@
1
- require 'spec_helper'
1
+ require 'rails_helper'
2
2
 
3
3
  describe RolesController do
4
4
  fixtures :all
@@ -1,18 +1,18 @@
1
- class CreateManifestations < ActiveRecord::Migration
1
+ class CreateManifestations < ActiveRecord::Migration[5.0]
2
2
  def change
3
- create_table :manifestations do |t|
4
- t.text :original_title, :null => false
3
+ create_table :manifestations, id: :uuid, default: 'gen_random_uuid()' do |t|
4
+ t.text :original_title, null: false
5
5
  t.text :title_alternative
6
6
  t.text :title_transcription
7
7
  t.string :classification_number
8
- t.string :manifestation_identifier
8
+ t.string :manifestation_identifier, index: {unique: true}
9
9
  t.datetime :date_of_publication
10
10
  t.datetime :copyright_date
11
11
  t.timestamps
12
12
  t.datetime :deleted_at
13
13
  t.string :access_address
14
- t.integer :language_id, :default => 1, :null => false
15
- t.integer :carrier_type_id, :default => 1, :null => false
14
+ t.integer :language_id, default: 1, null: false
15
+ t.references :carrier_type, null: false
16
16
  t.integer :start_page
17
17
  t.integer :end_page
18
18
  t.integer :height
@@ -25,18 +25,17 @@ class CreateManifestations < ActiveRecord::Migration
25
25
  t.string :serial_number_string
26
26
  t.integer :edition
27
27
  t.text :note
28
- t.boolean :repository_content, :default => false, :null => false
29
- t.integer :lock_version, :default => 0, :null => false
30
- t.integer :required_role_id, :default => 1, :null => false
31
- t.integer :required_score, :default => 0, :null => false
32
- t.integer :frequency_id, :default => 1, :null => false
33
- t.boolean :subscription_master, :default => false, :null => false
28
+ t.boolean :repository_content, default: false, null: false
29
+ t.integer :lock_version, default: 0, null: false
30
+ t.integer :required_role_id, default: 1, null: false
31
+ t.integer :required_score, default: 0, null: false
32
+ t.integer :frequency_id, default: 1, null: false
33
+ t.boolean :subscription_master, default: false, null: false
34
34
  end
35
35
  #add_index :manifestations, :carrier_type_id
36
36
  #add_index :manifestations, :required_role_id
37
37
  add_index :manifestations, :access_address
38
38
  #add_index :manifestations, :frequency_id
39
- add_index :manifestations, :manifestation_identifier
40
39
  add_index :manifestations, :updated_at
41
40
  add_index :manifestations, :date_of_publication
42
41
  end
@@ -1,20 +1,19 @@
1
- class CreateItems < ActiveRecord::Migration
1
+ class CreateItems < ActiveRecord::Migration[5.0]
2
2
  def change
3
- create_table :items do |t|
3
+ create_table :items, id: :uuid, default: 'gen_random_uuid()' do |t|
4
4
  t.string :call_number
5
5
  t.string :item_identifier
6
6
  t.timestamps
7
7
  t.datetime :deleted_at
8
- t.integer :shelf_id, :default => 1, :null => false
9
- t.boolean :include_supplements, :default => false, :null => false
8
+ t.references :shelf, default: 1
9
+ t.boolean :include_supplements, default: false, null: false
10
10
  t.text :note
11
11
  t.string :url
12
12
  t.integer :price
13
- t.integer :lock_version, :default => 0, :null => false
14
- t.integer :required_role_id, :default => 1, :null => false
15
- t.integer :required_score, :default => 0, :null => false
13
+ t.integer :lock_version, default: 0, null: false
14
+ t.integer :required_role_id, default: 1, null: false
15
+ t.integer :required_score, default: 0, null: false
16
16
  end
17
- add_index :items, :shelf_id
18
17
  add_index :items, :item_identifier
19
18
  add_index :items, :required_role_id
20
19
  end
@@ -1,12 +1,10 @@
1
- class CreateOwns < ActiveRecord::Migration
1
+ class CreateOwns < ActiveRecord::Migration[5.0]
2
2
  def change
3
3
  create_table :owns do |t|
4
- t.references :agent, :null => false
5
- t.references :item, :null => false
4
+ t.references :agent, null: false, foreign_key: true
5
+ t.references :item, null: false, foreign_key: true, type: :uuid
6
6
  t.integer :position
7
7
  t.timestamps
8
8
  end
9
- add_index :owns, :agent_id
10
- add_index :owns, :item_id
11
9
  end
12
10
  end
@@ -1,12 +1,10 @@
1
- class CreateCreates < ActiveRecord::Migration
1
+ class CreateCreates < ActiveRecord::Migration[5.0]
2
2
  def change
3
3
  create_table :creates do |t|
4
- t.references :agent, :null => false
5
- t.references :work, :null => false
4
+ t.references :agent, null: false, foreign_key: true
5
+ t.references :work, null: false, index: true, type: :uuid
6
6
  t.integer :position
7
7
  t.timestamps
8
8
  end
9
- add_index :creates, :agent_id
10
- add_index :creates, :work_id
11
9
  end
12
10
  end
@@ -1,12 +1,10 @@
1
- class CreateProduces < ActiveRecord::Migration
1
+ class CreateProduces < ActiveRecord::Migration[5.0]
2
2
  def change
3
3
  create_table :produces do |t|
4
- t.references :agent, :null => false
5
- t.references :manifestation, :null => false
4
+ t.references :agent, null: false, foreign_key: true
5
+ t.references :manifestation, null: false, foreign_key: true, type: :uuid
6
6
  t.integer :position
7
7
  t.timestamps
8
8
  end
9
- add_index :produces, :agent_id
10
- add_index :produces, :manifestation_id
11
9
  end
12
10
  end
@@ -1,9 +1,9 @@
1
- class CreateLibraries < ActiveRecord::Migration
1
+ class CreateLibraries < ActiveRecord::Migration[5.0]
2
2
  def change
3
- create_table :libraries do |t|
4
- t.string :name, :null => false
5
- t.text :display_name
6
- t.string :short_display_name, :null => false
3
+ create_table :libraries, id: :uuid, default: 'gen_random_uuid()' do |t|
4
+ t.string :name, null: false, index: {unique: true}
5
+ t.jsonb :display_name_translations
6
+ t.jsonb :short_display_name_translations
7
7
  t.string :zip_code
8
8
  t.text :street
9
9
  t.text :locality
@@ -12,10 +12,10 @@ class CreateLibraries < ActiveRecord::Migration
12
12
  t.string :telephone_number_2
13
13
  t.string :fax_number
14
14
  t.text :note
15
- t.integer :call_number_rows, :default => 1, :null => false
16
- t.string :call_number_delimiter, :default => "|", :null => false
17
- t.integer :library_group_id, :default => 1, :null => false
18
- t.integer :users_count, :default => 0, :null => false
15
+ t.integer :call_number_rows, default: 1, null: false
16
+ t.string :call_number_delimiter, default: "|", null: false
17
+ t.integer :library_group_id, default: 1, null: false
18
+ t.integer :users_count, default: 0, null: false
19
19
  t.integer :position
20
20
  t.integer :country_id
21
21
 
@@ -23,6 +23,5 @@ class CreateLibraries < ActiveRecord::Migration
23
23
  t.datetime :deleted_at
24
24
  end
25
25
  add_index :libraries, :library_group_id
26
- add_index :libraries, :name, :unique => true
27
26
  end
28
27
  end
@@ -1,15 +1,14 @@
1
- class CreateShelves < ActiveRecord::Migration
1
+ class CreateShelves < ActiveRecord::Migration[5.0]
2
2
  def change
3
3
  create_table :shelves do |t|
4
- t.string :name, :null => false
5
- t.text :display_name
4
+ t.string :name, null: false
5
+ t.jsonb :display_name_translations
6
6
  t.text :note
7
- t.integer :library_id, :default => 1, :null => false
8
- t.integer :items_count, :default => 0, :null => false
7
+ t.references :library, foreign_key: true, null: false, type: :uuid
8
+ t.integer :items_count, default: 0, null: false
9
9
  t.integer :position
10
10
  t.timestamps
11
11
  t.datetime :deleted_at
12
12
  end
13
- add_index :shelves, :library_id
14
13
  end
15
14
  end