spina-admin-conferences 1.3.3
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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +101 -0
- data/Rakefile +40 -0
- data/app/assets/config/spina_admin_conferences_manifest.js +4 -0
- data/app/assets/javascripts/spina/admin/conferences/application.es6 +20 -0
- data/app/assets/javascripts/spina/admin/conferences/controllers/conference_events_form_controller.es6 +175 -0
- data/app/assets/javascripts/spina/admin/conferences/controllers/presentation_attachments_form_controller.es6 +175 -0
- data/app/assets/javascripts/spina/admin/conferences/controllers/select_options_controller.es6 +216 -0
- data/app/assets/stylesheets/spina/admin/conferences/application.sass +14 -0
- data/app/controllers/spina/admin/conferences/application_controller.rb +20 -0
- data/app/controllers/spina/admin/conferences/conferences_controller.rb +148 -0
- data/app/controllers/spina/admin/conferences/delegates_controller.rb +116 -0
- data/app/controllers/spina/admin/conferences/dietary_requirements_controller.rb +106 -0
- data/app/controllers/spina/admin/conferences/events_controller.rb +24 -0
- data/app/controllers/spina/admin/conferences/institutions_controller.rb +106 -0
- data/app/controllers/spina/admin/conferences/presentation_attachment_types_controller.rb +104 -0
- data/app/controllers/spina/admin/conferences/presentation_attachments_controller.rb +24 -0
- data/app/controllers/spina/admin/conferences/presentation_types_controller.rb +109 -0
- data/app/controllers/spina/admin/conferences/presentations_controller.rb +124 -0
- data/app/controllers/spina/admin/conferences/rooms_controller.rb +109 -0
- data/app/controllers/spina/admin/conferences/sessions_controller.rb +118 -0
- data/app/helpers/spina/admin/conferences/conferences_helper.rb +44 -0
- data/app/jobs/spina/admin/conferences/application_job.rb +11 -0
- data/app/jobs/spina/admin/conferences/delegate_import_job.rb +37 -0
- data/app/jobs/spina/admin/conferences/import_job.rb +26 -0
- data/app/jobs/spina/admin/conferences/presentation_import_job.rb +38 -0
- data/app/mailers/spina/admin/conferences/application_mailer.rb +13 -0
- data/app/models/spina/admin/conferences.rb +11 -0
- data/app/models/spina/admin/conferences/application_record.rb +14 -0
- data/app/models/spina/admin/conferences/conference.rb +152 -0
- data/app/models/spina/admin/conferences/date_part.rb +15 -0
- data/app/models/spina/admin/conferences/delegate.rb +89 -0
- data/app/models/spina/admin/conferences/dietary_requirement.rb +33 -0
- data/app/models/spina/admin/conferences/email_address_part.rb +21 -0
- data/app/models/spina/admin/conferences/event.rb +120 -0
- data/app/models/spina/admin/conferences/institution.rb +46 -0
- data/app/models/spina/admin/conferences/part.rb +20 -0
- data/app/models/spina/admin/conferences/presentation.rb +143 -0
- data/app/models/spina/admin/conferences/presentation_attachment.rb +27 -0
- data/app/models/spina/admin/conferences/presentation_attachment_type.rb +35 -0
- data/app/models/spina/admin/conferences/presentation_type.rb +60 -0
- data/app/models/spina/admin/conferences/room.rb +52 -0
- data/app/models/spina/admin/conferences/session.rb +56 -0
- data/app/models/spina/admin/conferences/time_part.rb +53 -0
- data/app/models/spina/admin/conferences/url_part.rb +21 -0
- data/app/validators/spina/admin/conferences/conference_date_validator.rb +20 -0
- data/app/validators/spina/admin/conferences/email_address_validator.rb +28 -0
- data/app/validators/spina/admin/conferences/finish_date_validator.rb +20 -0
- data/app/validators/spina/admin/conferences/finish_time_validator.rb +20 -0
- data/app/validators/spina/admin/conferences/http_url_validator.rb +28 -0
- data/app/views/layouts/spina/admin/conferences/conferences.html.haml +19 -0
- data/app/views/layouts/spina/admin/conferences/delegates.html.haml +10 -0
- data/app/views/layouts/spina/admin/conferences/dietary_requirements.html.haml +10 -0
- data/app/views/layouts/spina/admin/conferences/institutions.html.haml +17 -0
- data/app/views/layouts/spina/admin/conferences/presentation_attachment_types.html.haml +10 -0
- data/app/views/layouts/spina/admin/conferences/presentations.html.haml +10 -0
- data/app/views/spina/admin/conferences/application/_empty_list.html.haml +3 -0
- data/app/views/spina/admin/conferences/application/_errors.html.haml +11 -0
- data/app/views/spina/admin/conferences/application/_errors.js.erb +2 -0
- data/app/views/spina/admin/conferences/conferences/_conference.html.haml +9 -0
- data/app/views/spina/admin/conferences/conferences/_event_fields.html.haml +39 -0
- data/app/views/spina/admin/conferences/conferences/_event_row.html.haml +5 -0
- data/app/views/spina/admin/conferences/conferences/_form.html.haml +23 -0
- data/app/views/spina/admin/conferences/conferences/_form_conference_details.html.haml +29 -0
- data/app/views/spina/admin/conferences/conferences/_form_delegates.html.haml +12 -0
- data/app/views/spina/admin/conferences/conferences/_form_parts.html.haml +15 -0
- data/app/views/spina/admin/conferences/conferences/_form_presentation_types.html.haml +12 -0
- data/app/views/spina/admin/conferences/conferences/_form_presentations.html.haml +12 -0
- data/app/views/spina/admin/conferences/conferences/_form_rooms.html.haml +12 -0
- data/app/views/spina/admin/conferences/conferences/_form_structure.html.haml +19 -0
- data/app/views/spina/admin/conferences/conferences/_form_structure_item.html.haml +13 -0
- data/app/views/spina/admin/conferences/conferences/edit.html.haml +1 -0
- data/app/views/spina/admin/conferences/conferences/index.html.haml +18 -0
- data/app/views/spina/admin/conferences/conferences/new.html.haml +1 -0
- data/app/views/spina/admin/conferences/delegates/_delegate.html.haml +13 -0
- data/app/views/spina/admin/conferences/delegates/_form.html.haml +23 -0
- data/app/views/spina/admin/conferences/delegates/_form_conferences.html.haml +14 -0
- data/app/views/spina/admin/conferences/delegates/_form_delegate_details.html.haml +38 -0
- data/app/views/spina/admin/conferences/delegates/_form_presentations.html.haml +12 -0
- data/app/views/spina/admin/conferences/delegates/edit.html.haml +1 -0
- data/app/views/spina/admin/conferences/delegates/index.html.haml +23 -0
- data/app/views/spina/admin/conferences/delegates/new.html.haml +1 -0
- data/app/views/spina/admin/conferences/dietary_requirements/_dietary_requirement.html.haml +6 -0
- data/app/views/spina/admin/conferences/dietary_requirements/_form.html.haml +23 -0
- data/app/views/spina/admin/conferences/dietary_requirements/_form_delegates.html.haml +12 -0
- data/app/views/spina/admin/conferences/dietary_requirements/_form_dietary_requirement_details.html.haml +9 -0
- data/app/views/spina/admin/conferences/dietary_requirements/edit.html.haml +1 -0
- data/app/views/spina/admin/conferences/dietary_requirements/index.html.haml +15 -0
- data/app/views/spina/admin/conferences/dietary_requirements/new.html.haml +1 -0
- data/app/views/spina/admin/conferences/events/new.js.erb +27 -0
- data/app/views/spina/admin/conferences/institutions/_form.html.haml +23 -0
- data/app/views/spina/admin/conferences/institutions/_form_delegates.html.haml +12 -0
- data/app/views/spina/admin/conferences/institutions/_form_institution_details.html.haml +35 -0
- data/app/views/spina/admin/conferences/institutions/_form_rooms.html.haml +12 -0
- data/app/views/spina/admin/conferences/institutions/_institution.html.haml +7 -0
- data/app/views/spina/admin/conferences/institutions/edit.html.haml +1 -0
- data/app/views/spina/admin/conferences/institutions/index.html.haml +16 -0
- data/app/views/spina/admin/conferences/institutions/new.html.haml +1 -0
- data/app/views/spina/admin/conferences/presentation_attachment_types/_form.html.haml +23 -0
- data/app/views/spina/admin/conferences/presentation_attachment_types/_presentation_attachment_type.html.haml +6 -0
- data/app/views/spina/admin/conferences/presentation_attachment_types/edit.html.haml +1 -0
- data/app/views/spina/admin/conferences/presentation_attachment_types/index.html.haml +15 -0
- data/app/views/spina/admin/conferences/presentation_attachment_types/new.html.haml +1 -0
- data/app/views/spina/admin/conferences/presentation_attachments/new.js.erb +21 -0
- data/app/views/spina/admin/conferences/presentation_types/_form.html.haml +23 -0
- data/app/views/spina/admin/conferences/presentation_types/_form_presentation_type_details.html.haml +20 -0
- data/app/views/spina/admin/conferences/presentation_types/_form_presentations.html.haml +12 -0
- data/app/views/spina/admin/conferences/presentation_types/_form_sessions.html.haml +12 -0
- data/app/views/spina/admin/conferences/presentation_types/_presentation_type.html.haml +8 -0
- data/app/views/spina/admin/conferences/presentation_types/edit.html.haml +1 -0
- data/app/views/spina/admin/conferences/presentation_types/index.html.haml +17 -0
- data/app/views/spina/admin/conferences/presentation_types/new.html.haml +1 -0
- data/app/views/spina/admin/conferences/presentations/_attachment_fields.html.haml +27 -0
- data/app/views/spina/admin/conferences/presentations/_attachment_row.html.haml +2 -0
- data/app/views/spina/admin/conferences/presentations/_form.html.haml +23 -0
- data/app/views/spina/admin/conferences/presentations/_form_presentation_details.html.haml +55 -0
- data/app/views/spina/admin/conferences/presentations/_form_presenters.html.haml +12 -0
- data/app/views/spina/admin/conferences/presentations/_presentation.html.haml +11 -0
- data/app/views/spina/admin/conferences/presentations/edit.html.haml +1 -0
- data/app/views/spina/admin/conferences/presentations/index.html.haml +23 -0
- data/app/views/spina/admin/conferences/presentations/new.html.haml +1 -0
- data/app/views/spina/admin/conferences/rooms/_form.html.haml +23 -0
- data/app/views/spina/admin/conferences/rooms/_form_presentations.html.haml +12 -0
- data/app/views/spina/admin/conferences/rooms/_form_room_details.html.haml +18 -0
- data/app/views/spina/admin/conferences/rooms/_room.html.haml +8 -0
- data/app/views/spina/admin/conferences/rooms/edit.html.haml +1 -0
- data/app/views/spina/admin/conferences/rooms/index.html.haml +17 -0
- data/app/views/spina/admin/conferences/rooms/new.html.haml +1 -0
- data/app/views/spina/admin/conferences/sessions/_form.html.haml +23 -0
- data/app/views/spina/admin/conferences/sessions/_form_presentations.html.haml +12 -0
- data/app/views/spina/admin/conferences/sessions/_form_session_details.html.haml +23 -0
- data/app/views/spina/admin/conferences/sessions/_session.html.haml +8 -0
- data/app/views/spina/admin/conferences/sessions/edit.html.haml +1 -0
- data/app/views/spina/admin/conferences/sessions/index.html.haml +17 -0
- data/app/views/spina/admin/conferences/sessions/new.html.haml +1 -0
- data/app/views/spina/admin/hooks/conferences/_head.html.haml +2 -0
- data/app/views/spina/admin/hooks/conferences/_primary_navigation.html.haml +20 -0
- data/app/views/spina/admin/hooks/conferences/_settings_secondary_navigation.html.haml +4 -0
- data/app/views/spina/admin/partables/admin/conferences/date_parts/_form.html.haml +5 -0
- data/app/views/spina/admin/partables/admin/conferences/email_address_parts/_form.html.haml +5 -0
- data/app/views/spina/admin/partables/admin/conferences/time_parts/_form.html.haml +7 -0
- data/app/views/spina/admin/partables/admin/conferences/url_parts/_form.html.haml +5 -0
- data/config/initializers/assets.rb +13 -0
- data/config/initializers/types.rb +13 -0
- data/config/locales/en.yml +354 -0
- data/config/routes.rb +27 -0
- data/db/migrate/20180907141228_create_spina_dates.rb +11 -0
- data/db/migrate/20180907141229_create_spina_email_addresses.rb +11 -0
- data/db/migrate/20180907141230_create_spina_urls.rb +11 -0
- data/db/migrate/20180907141231_create_spina_conferences_institutions.rb +12 -0
- data/db/migrate/20180907141232_create_spina_conferences_delegates.rb +15 -0
- data/db/migrate/20180907141234_create_spina_conferences_dietary_requirements.rb +11 -0
- data/db/migrate/20180907141235_create_spina_conferences_conferences.rb +12 -0
- data/db/migrate/20180907141236_create_spina_conferences_presentation_types.rb +13 -0
- data/db/migrate/20180907141238_create_join_table_spina_conferences_conference_delegate.rb +7 -0
- data/db/migrate/20180907141239_create_join_table_spina_conferences_delegate_presentation.rb +7 -0
- data/db/migrate/20180907141240_create_join_table_spina_conferences_delegate_dietary_requirement.rb +7 -0
- data/db/migrate/20180907141242_add_type_to_spina_pages.rb +7 -0
- data/db/migrate/20180907141243_create_spina_conferences_conference_page_parts.rb +14 -0
- data/db/migrate/20180914121905_add_logo_ref_to_spina_conferences_institutions.rb +7 -0
- data/db/migrate/20180916135431_create_spina_conferences_rooms.rb +13 -0
- data/db/migrate/20180916135432_create_spina_conferences_room_possessions.rb +10 -0
- data/db/migrate/20180916135433_create_spina_conferences_room_uses.rb +10 -0
- data/db/migrate/20180916135434_create_spina_conferences_presentations.rb +15 -0
- data/db/migrate/20181009122503_create_spina_times.rb +11 -0
- data/db/migrate/20181009130631_rename_spina_page_parts.rb +10 -0
- data/db/migrate/20181012190811_rename_spina_conferences_page_parts.rb +10 -0
- data/db/migrate/20181012213049_change_start_time_in_spina_conferences_conferences.rb +15 -0
- data/db/migrate/20181012214813_rename_start_time_in_spina_conferences_conferences.rb +7 -0
- data/db/migrate/20181017155705_add_dependent_option_to_foreign_keys.rb +36 -0
- data/db/migrate/20190408131354_change_spina_resources.rb +56 -0
- data/db/migrate/20190622131423_create_spina_conferences_parts.rb +12 -0
- data/db/migrate/20190701174807_remove_spina_conference_pages.rb +199 -0
- data/db/migrate/20190704135524_add_constraints_to_columns.rb +24 -0
- data/db/migrate/20200126034441_create_spina_conferences_presentation_attachment_types.rb +11 -0
- data/db/migrate/20200126213718_create_spina_conferences_presentation_attachments.rb +19 -0
- data/db/migrate/20200420104603_create_spina_conferences_dietary_requirement_name_translations.rb +19 -0
- data/db/migrate/20200420104740_create_spina_conferences_institution_name_and_city_translations.rb +20 -0
- data/db/migrate/20200420105057_create_spina_conferences_presentation_title_and_abstract_translations.rb +20 -0
- data/db/migrate/20200420105144_create_spina_conferences_presentation_attachment_type_name_translations.rb +20 -0
- data/db/migrate/20200420105201_create_spina_conferences_presentation_type_name_translations.rb +19 -0
- data/db/migrate/20200420105458_create_spina_conferences_room_building_and_number_translations.rb +20 -0
- data/db/migrate/20200420110407_move_attributes_to_translation_tables.rb +161 -0
- data/db/migrate/20200420120706_remove_name_from_spina_conferences_dietary_requirements.rb +7 -0
- data/db/migrate/20200420120759_remove_name_and_city_from_spina_conferences_institutions.rb +8 -0
- data/db/migrate/20200420120946_remove_title_and_abstract_from_spina_conferences_presentations.rb +8 -0
- data/db/migrate/20200420121310_remove_name_from_spina_conferences_presentation_attachment_types.rb +7 -0
- data/db/migrate/20200420121321_remove_name_from_spina_conferences_presentation_types.rb +7 -0
- data/db/migrate/20200420121443_remove_building_and_number_from_spina_conferences_rooms.rb +8 -0
- data/db/migrate/20200502133408_create_spina_conferences_conference_name_translations.rb +19 -0
- data/db/migrate/20200502183409_set_name_for_spina_conferences_conferences.rb +47 -0
- data/db/migrate/20200502183410_remove_institution_from_spina_conferences_conferences.rb +8 -0
- data/db/migrate/20200502183719_remove_spina_conferences_room_possessions.rb +60 -0
- data/db/migrate/20200503230732_rename_spina_conferences_room_uses.rb +8 -0
- data/db/migrate/20200510125131_create_spina_conferences_session_name_translations.rb +19 -0
- data/db/migrate/20200802165242_create_spina_conferences_events.rb +13 -0
- data/db/migrate/20200802184921_create_spina_conferences_event_name_description_and_location_translations.rb +21 -0
- data/db/migrate/20200911161632_update_spina_conferences_parts.rb +23 -0
- data/db/migrate/20200911161651_update_spina_parts.rb +37 -0
- data/db/migrate/20200911161726_move_presentation_parts.rb +101 -0
- data/db/migrate/20200911161739_move_conference_parts.rb +219 -0
- data/db/migrate/20201002122517_remove_spina_conferences_conference_page_parts.rb +14 -0
- data/db/migrate/20201007125625_add_timestamps_to_spina_conferences_parts.rb +9 -0
- data/lib/spina/admin/conferences.rb +20 -0
- data/lib/spina/admin/conferences/engine.rb +26 -0
- data/lib/spina/admin/conferences/migration/renaming.rb +81 -0
- data/lib/spina/admin/conferences/railtie.rb +34 -0
- data/lib/spina/admin/conferences/types/interval_type.rb +29 -0
- data/lib/spina/admin/conferences/version.rb +10 -0
- data/lib/tasks/spina/admin/conferences_tasks.rake +4 -0
- metadata +561 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class RemoveInstitutionFromSpinaConferencesConferences < ActiveRecord::Migration[6.0] # :nodoc:
|
|
4
|
+
def change
|
|
5
|
+
remove_reference :spina_conferences_conferences, :institution,
|
|
6
|
+
foreign_key: { to_table: :spina_conferences_institutions }
|
|
7
|
+
end
|
|
8
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class RemoveSpinaConferencesRoomPossessions < ActiveRecord::Migration[6.0] # :nodoc:
|
|
4
|
+
def up
|
|
5
|
+
add_reference :spina_conferences_room_uses, :room, foreign_key: { to_table: :spina_conferences_rooms }
|
|
6
|
+
add_timestamps :spina_conferences_room_uses, null: true
|
|
7
|
+
update_room_uses_with_room_id
|
|
8
|
+
remove_reference :spina_conferences_room_uses, :room_possession
|
|
9
|
+
drop_table :spina_conferences_room_possessions
|
|
10
|
+
change_column_null :spina_conferences_room_uses, :created_at, false
|
|
11
|
+
change_column_null :spina_conferences_room_uses, :updated_at, false
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def down
|
|
15
|
+
remove_timestamps :spina_conferences_room_uses
|
|
16
|
+
create_room_possessions_table
|
|
17
|
+
add_reference :spina_conferences_room_uses, :room_possession, foreign_key: { to_table: :spina_conferences_room_possessions }
|
|
18
|
+
insert_room_possessions
|
|
19
|
+
update_room_uses_with_room_possession_id
|
|
20
|
+
remove_reference :spina_conferences_room_uses, :room
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
private
|
|
24
|
+
|
|
25
|
+
def create_room_possessions_table
|
|
26
|
+
create_table 'spina_conferences_room_possessions' do |t| # rubocop:disable Rails/CreateTableWithTimestamps
|
|
27
|
+
t.references :room, foreign_key: { to_table: :spina_conferences_rooms }
|
|
28
|
+
t.references :conference, foreign_key: { to_table: :spina_conferences_conferences }
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def update_room_uses_with_room_id
|
|
33
|
+
update <<-SQL.squish, 'Update room uses'
|
|
34
|
+
UPDATE spina_conferences_room_uses
|
|
35
|
+
SET (room_id, created_at, updated_at) = (spina_conferences_room_possessions.room_id, current_timestamp, current_timestamp)
|
|
36
|
+
FROM spina_conferences_room_possessions
|
|
37
|
+
WHERE spina_conferences_room_possessions.id = spina_conferences_room_uses.room_possession_id
|
|
38
|
+
SQL
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def insert_room_possessions
|
|
42
|
+
insert <<-SQL.squish, 'Add room possessions'
|
|
43
|
+
INSERT INTO spina_conferences_room_possessions (room_id, conference_id)
|
|
44
|
+
SELECT DISTINCT spina_conferences_room_uses.room_id, spina_conferences_presentation_types.conference_id
|
|
45
|
+
FROM spina_conferences_room_uses
|
|
46
|
+
INNER JOIN spina_conferences_presentation_types
|
|
47
|
+
ON spina_conferences_presentation_types.id = spina_conferences_room_uses.presentation_type_id
|
|
48
|
+
SQL
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def update_room_uses_with_room_possession_id
|
|
52
|
+
update <<-SQL.squish, 'Add references to room uses'
|
|
53
|
+
UPDATE spina_conferences_room_uses SET room_possession_id = spina_conferences_room_possessions.id
|
|
54
|
+
FROM spina_conferences_room_possessions
|
|
55
|
+
INNER JOIN spina_conferences_presentation_types USING (conference_id)
|
|
56
|
+
WHERE spina_conferences_room_possessions.room_id = spina_conferences_room_uses.room_id
|
|
57
|
+
AND spina_conferences_room_possessions.conference_id = spina_conferences_presentation_types.conference_id
|
|
58
|
+
SQL
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class RenameSpinaConferencesRoomUses < ActiveRecord::Migration[6.0] # :nodoc:
|
|
4
|
+
def change
|
|
5
|
+
rename_table :spina_conferences_room_uses, :spina_conferences_sessions
|
|
6
|
+
rename_column :spina_conferences_presentations, :room_use_id, :session_id
|
|
7
|
+
end
|
|
8
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class CreateSpinaConferencesSessionNameTranslations < ActiveRecord::Migration[6.0] # :nodoc:
|
|
4
|
+
def change
|
|
5
|
+
create_table :spina_conferences_session_translations do |t|
|
|
6
|
+
# Translated attribute(s)
|
|
7
|
+
t.string :name
|
|
8
|
+
|
|
9
|
+
t.string :locale, null: false
|
|
10
|
+
t.references :spina_conferences_session, null: false, foreign_key: true, index: false
|
|
11
|
+
|
|
12
|
+
t.timestamps null: false
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
add_index :spina_conferences_session_translations, :locale, name: :index_spina_conferences_session_translations_on_locale
|
|
16
|
+
add_index :spina_conferences_session_translations, %i[spina_conferences_session_id locale],
|
|
17
|
+
name: :index_7843e68c4bf93df06700ea7f68c4765ef004169a, unique: true
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class CreateSpinaConferencesEvents < ActiveRecord::Migration[6.0] # :nodoc:
|
|
4
|
+
def change
|
|
5
|
+
create_table :spina_conferences_events do |t|
|
|
6
|
+
t.datetime :start_datetime
|
|
7
|
+
t.datetime :finish_datetime
|
|
8
|
+
t.references :conference, foreign_key: { to_table: :spina_conferences_conferences, on_delete: :cascade }
|
|
9
|
+
|
|
10
|
+
t.timestamps
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class CreateSpinaConferencesEventNameDescriptionAndLocationTranslations < ActiveRecord::Migration[6.0] # rubocop:disable Style/Documentation
|
|
4
|
+
def change # rubocop:disable Metrics/MethodLength
|
|
5
|
+
create_table :spina_conferences_event_translations do |t|
|
|
6
|
+
# Translated attribute(s)
|
|
7
|
+
t.string :name
|
|
8
|
+
t.text :description
|
|
9
|
+
t.string :location
|
|
10
|
+
|
|
11
|
+
t.string :locale, null: false
|
|
12
|
+
t.references :spina_conferences_event, null: false, foreign_key: true, index: false
|
|
13
|
+
|
|
14
|
+
t.timestamps null: false
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
add_index :spina_conferences_event_translations, :locale, name: :index_spina_conferences_event_translations_on_locale
|
|
18
|
+
add_index :spina_conferences_event_translations, %i[spina_conferences_event_id locale],
|
|
19
|
+
name: :index_a26428290c005036f14c7c9cab5f5a91289e46e0, unique: true
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class UpdateSpinaConferencesParts < ActiveRecord::Migration[6.0] # :nodoc:
|
|
4
|
+
def up
|
|
5
|
+
update <<-SQL.squish, 'Add namespacing to class names'
|
|
6
|
+
UPDATE spina_conferences_parts
|
|
7
|
+
SET
|
|
8
|
+
partable_type = replace(partable_type, 'Spina::Conferences', 'Spina::Admin::Conferences'),
|
|
9
|
+
pageable_type = replace(pageable_type, 'Spina::Conferences', 'Spina::Admin::Conferences')
|
|
10
|
+
WHERE starts_with(partable_type, 'Spina::Conferences') OR starts_with(pageable_type, 'Spina::Conferences')
|
|
11
|
+
SQL
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def down
|
|
15
|
+
update <<-SQL.squish, 'Remove namespacing from class names'
|
|
16
|
+
UPDATE spina_conferences_parts
|
|
17
|
+
SET
|
|
18
|
+
partable_type = replace(partable_type, 'Spina::Admin::Conferences', 'Spina::Conferences'),
|
|
19
|
+
pageable_type = replace(pageable_type, 'Spina::Admin::Conferences', 'Spina::Conferences')
|
|
20
|
+
WHERE starts_with(partable_type, 'Spina::Admin::Conferences') OR starts_with(pageable_type, 'Spina::Admin::Conferences')
|
|
21
|
+
SQL
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class UpdateSpinaParts < ActiveRecord::Migration[6.0] # :nodoc:
|
|
4
|
+
def up
|
|
5
|
+
update <<-SQL.squish, 'Add namespacing to class names for page parts'
|
|
6
|
+
UPDATE spina_page_parts SET page_partable_type = replace(page_partable_type, 'Spina::Conferences', 'Spina::Admin::Conferences')
|
|
7
|
+
WHERE starts_with(page_partable_type, 'Spina::Conferences')
|
|
8
|
+
SQL
|
|
9
|
+
update <<-SQL.squish, 'Add namespacing to class names for structure parts'
|
|
10
|
+
UPDATE spina_structure_parts
|
|
11
|
+
SET structure_partable_type = replace(structure_partable_type, 'Spina::Conferences', 'Spina::Admin::Conferences')
|
|
12
|
+
WHERE starts_with(structure_partable_type, 'Spina::Conferences')
|
|
13
|
+
SQL
|
|
14
|
+
update <<-SQL.squish, 'Add namespacing to class names for layout parts'
|
|
15
|
+
UPDATE spina_layout_parts
|
|
16
|
+
SET layout_partable_type = replace(layout_partable_type, 'Spina::Conferences', 'Spina::Admin::Conferences')
|
|
17
|
+
WHERE starts_with(layout_partable_type, 'Spina::Conferences')
|
|
18
|
+
SQL
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def down
|
|
22
|
+
update <<-SQL.squish, 'Remove namespacing from class names for page parts'
|
|
23
|
+
UPDATE spina_page_parts SET page_partable_type = replace(page_partable_type, 'Spina::Admin::Conferences', 'Spina::Conferences')
|
|
24
|
+
WHERE starts_with(page_partable_type, 'Spina::Admin::Conferences')
|
|
25
|
+
SQL
|
|
26
|
+
update <<-SQL.squish, 'Remove namespacing from class names for structure parts'
|
|
27
|
+
UPDATE spina_structure_parts
|
|
28
|
+
SET structure_partable_type = replace(structure_partable_type, 'Spina::Admin::Conferences', 'Spina::Conferences')
|
|
29
|
+
WHERE starts_with(structure_partable_type, 'Spina::Admin::Conferences')
|
|
30
|
+
SQL
|
|
31
|
+
update <<-SQL.squish, 'Remove namespacing from class names for layout parts'
|
|
32
|
+
UPDATE spina_layout_parts
|
|
33
|
+
SET layout_partable_type = replace(layout_partable_type, 'Spina::Admin::Conferences', 'Spina::Conferences')
|
|
34
|
+
WHERE starts_with(layout_partable_type, 'Spina::Admin::Conferences')
|
|
35
|
+
SQL
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class MovePresentationParts < ActiveRecord::Migration[6.0] # :nodoc:
|
|
4
|
+
def up
|
|
5
|
+
create_presentation_attachment_types
|
|
6
|
+
create_presentation_attachments
|
|
7
|
+
delete_presentation_parts
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def down
|
|
11
|
+
create_parts
|
|
12
|
+
delete_presentation_attachments
|
|
13
|
+
delete_presentation_attachment_type_translations
|
|
14
|
+
delete_presentation_attachment_types
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def create_presentation_attachment_types
|
|
20
|
+
binds = [ActiveRecord::Relation::QueryAttribute.new('locale', I18n.default_locale, ActiveRecord::Type::String.new)]
|
|
21
|
+
insert <<-SQL.squish, 'Create presentation attachment types', nil, nil, nil, binds
|
|
22
|
+
WITH attachment_type_names AS (
|
|
23
|
+
SELECT DISTINCT ON (title) title, id
|
|
24
|
+
FROM spina_conferences_parts
|
|
25
|
+
WHERE pageable_type = 'Spina::Admin::Conferences::Presentation' AND partable_type = 'Spina::Attachment'
|
|
26
|
+
ORDER BY title
|
|
27
|
+
), attachment_types AS (
|
|
28
|
+
INSERT INTO spina_conferences_presentation_attachment_types (created_at, updated_at)
|
|
29
|
+
SELECT current_timestamp, current_timestamp FROM attachment_type_names
|
|
30
|
+
RETURNING id
|
|
31
|
+
)
|
|
32
|
+
INSERT INTO spina_conferences_presentation_attachment_type_translations
|
|
33
|
+
(name, locale, spina_conferences_presentation_attachment_type_id, created_at, updated_at)
|
|
34
|
+
SELECT title, $1, id, current_timestamp, current_timestamp
|
|
35
|
+
FROM (
|
|
36
|
+
SELECT title, row_number() over (ORDER BY id) AS index FROM attachment_type_names
|
|
37
|
+
) AS attachment_type_names_with_indices
|
|
38
|
+
INNER JOIN (
|
|
39
|
+
SELECT id, row_number() over (ORDER BY id) AS index FROM attachment_types
|
|
40
|
+
) AS attachment_types_with_indices USING (index)
|
|
41
|
+
SQL
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def create_presentation_attachments
|
|
45
|
+
binds = [ActiveRecord::Relation::QueryAttribute.new('locale', I18n.default_locale, ActiveRecord::Type::String.new)]
|
|
46
|
+
insert <<-SQL.squish, 'Create presentation attachments', nil, nil, nil, binds
|
|
47
|
+
INSERT INTO spina_conferences_presentation_attachments (presentation_id, attachment_type_id, attachment_id, created_at, updated_at)
|
|
48
|
+
SELECT pageable_id, spina_conferences_presentation_attachment_type_id, partable_id, current_timestamp, current_timestamp
|
|
49
|
+
FROM spina_conferences_parts
|
|
50
|
+
INNER JOIN spina_conferences_presentation_attachment_type_translations
|
|
51
|
+
ON spina_conferences_parts.name = replace(lower(spina_conferences_presentation_attachment_type_translations.name),'\W', '_')
|
|
52
|
+
AND locale = $1
|
|
53
|
+
WHERE pageable_type = 'Spina::Admin::Conferences::Presentation'
|
|
54
|
+
AND partable_type = 'Spina::Attachment'
|
|
55
|
+
SQL
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def delete_presentation_parts
|
|
59
|
+
delete <<-SQL.squish, 'Delete presentation parts'
|
|
60
|
+
DELETE FROM spina_conferences_parts
|
|
61
|
+
WHERE pageable_type = 'Spina::Admin::Conferences::Presentation' AND partable_type = 'Spina::Attachment'
|
|
62
|
+
SQL
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def create_parts
|
|
66
|
+
insert <<-SQL.squish, 'Create parts'
|
|
67
|
+
INSERT INTO spina_conferences_parts (title, name, partable_type, partable_id, pageable_type, pageable_id)
|
|
68
|
+
SELECT name, replace(lower(name),'\W', '_'), 'Spina::Admin::Conferences::Presentation', presentation_id, 'Spina::Attachment',
|
|
69
|
+
attachment_id
|
|
70
|
+
FROM spina_conferences_presentation_attachments
|
|
71
|
+
INNER JOIN spina_conferences_presentation_attachment_type_translations
|
|
72
|
+
ON attachment_type_id = spina_conferences_presentation_attachment_type_id
|
|
73
|
+
SQL
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def delete_presentation_attachments
|
|
77
|
+
delete <<-SQL.squish, 'Delete presentation attachments'
|
|
78
|
+
DELETE FROM spina_conferences_presentation_attachments
|
|
79
|
+
USING spina_conferences_parts
|
|
80
|
+
WHERE title = name AND pageable_id = presentation_id
|
|
81
|
+
SQL
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def delete_presentation_attachment_type_translations
|
|
85
|
+
delete <<-SQL.squish, 'Delete presentation attachment type translations'
|
|
86
|
+
DELETE FROM spina_conferences_presentation_attachment_type_translations
|
|
87
|
+
USING spina_conferences_presentation_attachments, spina_conferences_parts
|
|
88
|
+
WHERE attachment_type_id != spina_conferences_presentation_attachment_type_id
|
|
89
|
+
AND spina_conferences_presentation_attachment_type_translations.name = title
|
|
90
|
+
SQL
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def delete_presentation_attachment_types
|
|
94
|
+
delete <<-SQL.squish, 'Delete presentation attachment types'
|
|
95
|
+
DELETE FROM spina_conferences_presentation_attachment_types
|
|
96
|
+
USING spina_conferences_presentation_attachments, spina_conferences_presentation_attachment_type_translations
|
|
97
|
+
WHERE attachment_type_id != spina_conferences_presentation_attachments.id
|
|
98
|
+
AND spina_conferences_presentation_attachment_type_id != spina_conferences_presentation_attachments.id
|
|
99
|
+
SQL
|
|
100
|
+
end
|
|
101
|
+
end
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class MoveConferenceParts < ActiveRecord::Migration[6.0] # rubocop:disable Metrics/ClassLength, Style/Documentation
|
|
4
|
+
def up
|
|
5
|
+
insert <<-SQL.squish, 'Create events', nil, nil, nil
|
|
6
|
+
WITH event_structure_items_with_parts AS (
|
|
7
|
+
SELECT DISTINCT
|
|
8
|
+
spina_structure_items.id AS structure_item_id,
|
|
9
|
+
pageable_id AS conference_id,
|
|
10
|
+
structure_id,
|
|
11
|
+
start_times.content AS start_time,
|
|
12
|
+
names.content AS title,
|
|
13
|
+
locations.content AS location,
|
|
14
|
+
descriptions.content AS description,
|
|
15
|
+
names.locale AS locale,
|
|
16
|
+
start_times.id AS start_time_id,
|
|
17
|
+
names.id AS title_translation_id,
|
|
18
|
+
locations.id AS location_translation_id,
|
|
19
|
+
descriptions.id AS description_translation_id
|
|
20
|
+
FROM spina_conferences_parts
|
|
21
|
+
INNER JOIN spina_structure_items ON partable_id = structure_id AND partable_type = 'Spina::Structure'
|
|
22
|
+
LEFT JOIN (
|
|
23
|
+
SELECT spina_conferences_time_parts.id AS id, spina_conferences_time_parts.content AS content, structure_item_id
|
|
24
|
+
FROM spina_structure_parts
|
|
25
|
+
INNER JOIN spina_conferences_time_parts
|
|
26
|
+
ON structure_partable_id = spina_conferences_time_parts.id
|
|
27
|
+
AND structure_partable_type = 'Spina::Admin::Conferences::TimePart'
|
|
28
|
+
AND spina_structure_parts.name = 'start_time'
|
|
29
|
+
) AS start_times ON start_times.structure_item_id = spina_structure_items.id
|
|
30
|
+
LEFT JOIN (
|
|
31
|
+
SELECT
|
|
32
|
+
spina_lines.id AS id, content, locale, structure_item_id
|
|
33
|
+
FROM spina_structure_parts
|
|
34
|
+
INNER JOIN spina_lines
|
|
35
|
+
ON structure_partable_id = spina_lines.id
|
|
36
|
+
AND structure_partable_type = 'Spina::Line'
|
|
37
|
+
AND spina_structure_parts.name = 'name'
|
|
38
|
+
INNER JOIN spina_line_translations
|
|
39
|
+
ON spina_line_id = spina_lines.id
|
|
40
|
+
WHERE content IS NOT NULL
|
|
41
|
+
) AS names ON names.structure_item_id = spina_structure_items.id
|
|
42
|
+
LEFT JOIN (
|
|
43
|
+
SELECT spina_lines.id AS id, content, locale, structure_item_id
|
|
44
|
+
FROM spina_structure_parts
|
|
45
|
+
INNER JOIN spina_lines
|
|
46
|
+
ON structure_partable_id = spina_lines.id
|
|
47
|
+
AND structure_partable_type = 'Spina::Line'
|
|
48
|
+
AND spina_structure_parts.name = 'location'
|
|
49
|
+
INNER JOIN spina_line_translations
|
|
50
|
+
ON spina_line_id = spina_lines.id
|
|
51
|
+
WHERE content IS NOT NULL
|
|
52
|
+
) AS locations ON locations.structure_item_id = spina_structure_items.id
|
|
53
|
+
LEFT JOIN (
|
|
54
|
+
SELECT spina_texts.id AS id, content, locale, structure_item_id
|
|
55
|
+
FROM spina_structure_parts
|
|
56
|
+
INNER JOIN spina_texts
|
|
57
|
+
ON structure_partable_id = spina_texts.id
|
|
58
|
+
AND structure_partable_type = 'Spina::Text'
|
|
59
|
+
AND spina_structure_parts.name = 'description'
|
|
60
|
+
INNER JOIN spina_text_translations
|
|
61
|
+
ON spina_text_id = spina_texts.id
|
|
62
|
+
WHERE content IS NOT NULL
|
|
63
|
+
) AS descriptions ON descriptions.structure_item_id = spina_structure_items.id
|
|
64
|
+
WHERE pageable_type = 'Spina::Admin::Conferences::Conference'
|
|
65
|
+
AND spina_conferences_parts.name IN ('meetings', 'socials')
|
|
66
|
+
AND names.locale = locations.locale
|
|
67
|
+
AND locations.locale = descriptions.locale
|
|
68
|
+
), untranslated_event_structure_items_with_parts AS (
|
|
69
|
+
SELECT DISTINCT ON (structure_item_id) structure_item_id, start_time, conference_id
|
|
70
|
+
FROM event_structure_items_with_parts
|
|
71
|
+
), events AS (
|
|
72
|
+
INSERT INTO spina_conferences_events (start_datetime, finish_datetime, conference_id, created_at, updated_at)
|
|
73
|
+
SELECT start_time, start_time + interval '1 hour', conference_id, current_timestamp, current_timestamp
|
|
74
|
+
FROM untranslated_event_structure_items_with_parts
|
|
75
|
+
RETURNING id
|
|
76
|
+
), event_translations AS (
|
|
77
|
+
INSERT INTO spina_conferences_event_translations
|
|
78
|
+
(name, description, location, locale, spina_conferences_event_id, created_at, updated_at)
|
|
79
|
+
SELECT DISTINCT ON (event_structure_items_with_parts_and_indices.structure_item_id, locale)
|
|
80
|
+
title, description, location, locale, structure_item_events.id, current_timestamp, current_timestamp
|
|
81
|
+
FROM (
|
|
82
|
+
SELECT structure_item_id, row_number() OVER (ORDER BY structure_item_id) AS index
|
|
83
|
+
FROM untranslated_event_structure_items_with_parts
|
|
84
|
+
) AS event_structure_items_with_parts_and_indices
|
|
85
|
+
INNER JOIN (SELECT id, row_number() OVER (ORDER BY id) AS index FROM events) AS structure_item_events
|
|
86
|
+
ON structure_item_events.index = event_structure_items_with_parts_and_indices.index
|
|
87
|
+
INNER JOIN event_structure_items_with_parts
|
|
88
|
+
ON event_structure_items_with_parts.structure_item_id = event_structure_items_with_parts_and_indices.structure_item_id
|
|
89
|
+
), line_translations AS (
|
|
90
|
+
DELETE FROM spina_line_translations
|
|
91
|
+
USING event_structure_items_with_parts
|
|
92
|
+
WHERE id IN (title_translation_id, location_translation_id)
|
|
93
|
+
RETURNING spina_line_id
|
|
94
|
+
), lines AS (
|
|
95
|
+
DELETE FROM spina_lines USING line_translations WHERE spina_line_id = id RETURNING id
|
|
96
|
+
), text_translations AS (
|
|
97
|
+
DELETE FROM spina_text_translations
|
|
98
|
+
USING event_structure_items_with_parts
|
|
99
|
+
WHERE id = description_translation_id
|
|
100
|
+
RETURNING spina_text_id
|
|
101
|
+
), texts AS (
|
|
102
|
+
DELETE FROM spina_texts USING text_translations WHERE spina_text_id = id RETURNING id
|
|
103
|
+
), times AS (
|
|
104
|
+
DELETE FROM spina_conferences_time_parts USING event_structure_items_with_parts WHERE id = start_time_id RETURNING id
|
|
105
|
+
), structure_parts AS (
|
|
106
|
+
DELETE FROM spina_structure_parts
|
|
107
|
+
USING lines, texts, times
|
|
108
|
+
WHERE
|
|
109
|
+
(structure_partable_id = lines.id AND structure_partable_type = 'Spina::Line')
|
|
110
|
+
OR (structure_partable_id = texts.id AND structure_partable_type = 'Spina::Text')
|
|
111
|
+
OR (structure_partable_id = times.id AND structure_partable_type = 'Spina::Admin::Conferences::TimePart')
|
|
112
|
+
RETURNING structure_item_id
|
|
113
|
+
), structure_items AS (
|
|
114
|
+
DELETE FROM spina_structure_items USING structure_parts WHERE structure_item_id = spina_structure_items.id RETURNING structure_id
|
|
115
|
+
), structures AS (
|
|
116
|
+
DELETE FROM spina_structures USING structure_items WHERE structure_id = spina_structures.id
|
|
117
|
+
)
|
|
118
|
+
DELETE FROM spina_conferences_parts
|
|
119
|
+
USING event_structure_items_with_parts WHERE partable_id = structure_id AND partable_type = 'Spina::Structure'
|
|
120
|
+
SQL
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
def down
|
|
124
|
+
binds = [ActiveRecord::Relation::QueryAttribute.new('locale', I18n.default_locale, ActiveRecord::Type::String.new)]
|
|
125
|
+
delete <<-SQL.squish, 'Create events', binds
|
|
126
|
+
WITH
|
|
127
|
+
conferences AS (SELECT DISTINCT ON (conference_id) conference_id AS id FROM spina_conferences_events),
|
|
128
|
+
structures AS (
|
|
129
|
+
INSERT INTO spina_structures (created_at, updated_at) SELECT current_timestamp, current_timestamp FROM conferences RETURNING id
|
|
130
|
+
), parts AS (
|
|
131
|
+
INSERT INTO spina_conferences_parts (title, name, partable_type, partable_id, pageable_type, pageable_id)
|
|
132
|
+
SELECT
|
|
133
|
+
'Events', 'events', 'Spina::Structure', structures_with_indices.id, 'Spina::Admin::Conferences::Conference', conferences.id
|
|
134
|
+
FROM (SELECT id, row_number() OVER (ORDER BY id) AS index FROM structures) AS structures_with_indices
|
|
135
|
+
INNER JOIN (SELECT id, row_number() OVER (ORDER BY id) AS index FROM conferences) AS conferences_with_indices USING (index)
|
|
136
|
+
), events AS (
|
|
137
|
+
SELECT spina_conferences_events.id AS id, name, description, location, locale, start_datetime, conference_id
|
|
138
|
+
FROM spina_conferences_events
|
|
139
|
+
INNER JOIN spina_conferences_event_translations ON spina_conferences_event_id = spina_conferences_events.id AND locale = $1
|
|
140
|
+
), structure_items AS (
|
|
141
|
+
INSERT INTO spina_structure_items (structure_id, position, created_at, updated_at)
|
|
142
|
+
SELECT structures_with_indices.id, events_with_indices.index, current_timestamp, current_timestamp
|
|
143
|
+
FROM (SELECT conference_id, row_number() over (ORDER BY id) AS index FROM events) AS events_with_indices
|
|
144
|
+
INNER JOIN (SELECT id, row_number() OVER (ORDER BY id) AS index FROM conferences) AS conferences_with_indices
|
|
145
|
+
ON conference_id = conferences_with_indices.id
|
|
146
|
+
INNER JOIN (SELECT id, row_number() OVER (ORDER BY id) AS index FROM structures) AS structures_with_indices
|
|
147
|
+
ON conferences_with_indices.index = structures_with_indices.index
|
|
148
|
+
RETURNING id
|
|
149
|
+
), line_parts AS (
|
|
150
|
+
SELECT id AS event_id, name AS content, 'Spina::Line' AS type, 'Title' AS title FROM events
|
|
151
|
+
UNION ALL SELECT id, location, 'Spina::Line', 'Location' FROM events
|
|
152
|
+
ORDER BY event_id, title
|
|
153
|
+
), text_parts AS (
|
|
154
|
+
SELECT id AS event_id, name AS content, 'Spina::Text' AS type, 'Description' AS title FROM events ORDER BY event_id, title
|
|
155
|
+
), datetime_parts AS (
|
|
156
|
+
SELECT id AS event_id, start_datetime AS content, 'Spina::Admin::Conferences::TimePart' AS type, 'Start time' AS title
|
|
157
|
+
FROM events
|
|
158
|
+
ORDER BY event_id, title
|
|
159
|
+
), lines AS (
|
|
160
|
+
INSERT INTO spina_lines (created_at, updated_at) SELECT current_timestamp, current_timestamp FROM line_parts RETURNING id
|
|
161
|
+
), line_translations AS (
|
|
162
|
+
INSERT INTO spina_line_translations (spina_line_id, locale, content, created_at, updated_at)
|
|
163
|
+
SELECT lines_with_indices.id, $1, content, current_timestamp, current_timestamp
|
|
164
|
+
FROM (SELECT content, type, row_number() OVER (ORDER BY event_id, title) AS index FROM line_parts) AS line_parts_with_indices
|
|
165
|
+
INNER JOIN (SELECT id, row_number() OVER (ORDER BY id) AS index FROM lines) AS lines_with_indices USING (index)
|
|
166
|
+
RETURNING id
|
|
167
|
+
), texts AS (
|
|
168
|
+
INSERT INTO spina_texts (created_at, updated_at)
|
|
169
|
+
SELECT current_timestamp, current_timestamp FROM text_parts ORDER BY event_id, title
|
|
170
|
+
RETURNING id
|
|
171
|
+
), text_translations AS (
|
|
172
|
+
INSERT INTO spina_text_translations (spina_text_id, locale, content, created_at, updated_at)
|
|
173
|
+
SELECT texts_with_indices.id, $1, content, current_timestamp, current_timestamp
|
|
174
|
+
FROM (SELECT content, type, row_number() OVER (ORDER BY event_id, title) AS index FROM text_parts) AS text_parts_with_indices
|
|
175
|
+
INNER JOIN (SELECT id, row_number() OVER (ORDER BY id) AS index FROM lines) AS texts_with_indices USING (index)
|
|
176
|
+
RETURNING id
|
|
177
|
+
), times AS (
|
|
178
|
+
INSERT INTO spina_conferences_time_parts (content, created_at, updated_at)
|
|
179
|
+
SELECT content, current_timestamp, current_timestamp FROM datetime_parts
|
|
180
|
+
RETURNING id
|
|
181
|
+
), structure_parts_to_insert AS (
|
|
182
|
+
SELECT partable_id, type, title, event_id
|
|
183
|
+
FROM (SELECT id as partable_id, row_number() OVER (ORDER BY id) AS index FROM lines) AS lines_with_indices
|
|
184
|
+
INNER JOIN (
|
|
185
|
+
SELECT type, title, event_id, row_number() OVER (ORDER BY event_id, title) AS index FROM line_parts WHERE type = 'Spina::Line'
|
|
186
|
+
) AS line_parts_with_indices USING (index)
|
|
187
|
+
UNION ALL
|
|
188
|
+
SELECT partable_id, type, title, event_id
|
|
189
|
+
FROM (SELECT id as partable_id, row_number() OVER (ORDER BY id) AS index FROM texts) AS texts_with_indices
|
|
190
|
+
INNER JOIN (
|
|
191
|
+
SELECT type, title, event_id, row_number() OVER (ORDER BY event_id, title) AS index
|
|
192
|
+
FROM text_parts
|
|
193
|
+
WHERE type = 'Spina::Text'
|
|
194
|
+
) AS text_parts_with_indices USING (index)
|
|
195
|
+
UNION ALL
|
|
196
|
+
SELECT partable_id, type, title, event_id
|
|
197
|
+
FROM (SELECT id as partable_id, row_number() OVER (ORDER BY id) AS index FROM times) AS times_with_indices
|
|
198
|
+
INNER JOIN (
|
|
199
|
+
SELECT type, title, event_id, row_number() OVER (ORDER BY event_id, title) AS index
|
|
200
|
+
FROM datetime_parts
|
|
201
|
+
WHERE type = 'Spina::Text'
|
|
202
|
+
) AS time_parts_with_indices USING (index)
|
|
203
|
+
), structure_parts AS (
|
|
204
|
+
INSERT INTO spina_structure_parts
|
|
205
|
+
(structure_item_id, structure_partable_id, structure_partable_type, name, title, created_at, updated_at)
|
|
206
|
+
SELECT
|
|
207
|
+
structure_items_with_indices.id, partable_id, type, replace(lower(title), '\W', '_'), title, current_timestamp,
|
|
208
|
+
current_timestamp
|
|
209
|
+
FROM structure_parts_to_insert
|
|
210
|
+
INNER JOIN (SELECT id, row_number() OVER (ORDER BY id) AS index FROM events) AS events_with_indices ON event_id = events.id
|
|
211
|
+
INNER JOIN (SELECT id, row_number() OVER (ORDER BY id) AS index FROM structure_items) AS structure_items_with_indices
|
|
212
|
+
USING (index)
|
|
213
|
+
), deleted_events AS (
|
|
214
|
+
DELETE FROM spina_conferences_events RETURNING id
|
|
215
|
+
)
|
|
216
|
+
DELETE FROM spina_conferences_event_translations USING deleted_events WHERE spina_conferences_event_id = deleted_events.id
|
|
217
|
+
SQL
|
|
218
|
+
end
|
|
219
|
+
end
|