forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path20101210192618_init_canvas_db.rb
3612 lines (3271 loc) · 159 KB
/
20101210192618_init_canvas_db.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# frozen_string_literal: true
#
# Copyright (C) 2011 - present Instructure, Inc.
#
# This file is part of Canvas.
#
# Canvas is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, version 3 of the License.
#
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
# details.
#
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# rubocop:disable Migration/PrimaryKey
class InitCanvasDb < ActiveRecord::Migration[4.2]
tag :predeploy
def self.up
connection.transaction(requires_new: true) do
create_extension(:pg_collkey, schema: connection.shard.name, if_not_exists: true)
rescue ActiveRecord::StatementInvalid
raise ActiveRecord::Rollback
end
connection.transaction(requires_new: true) do
create_extension(:pg_trgm, schema: connection.shard.name, if_not_exists: true)
rescue ActiveRecord::StatementInvalid
raise ActiveRecord::Rollback
end
# everything else is alphabetical,
# sometimes defining classes try to access
# this table def and it needs to exist first
create_table "settings", force: true do |t|
t.string "name", limit: 255
t.text "value"
t.datetime "created_at"
t.datetime "updated_at"
end
add_index :settings, :name, unique: true
create_table "abstract_courses", force: true do |t|
t.string "sis_source_id", limit: 255
t.integer "sis_batch_id", limit: 8
t.integer "account_id", limit: 8, null: false
t.integer "root_account_id", limit: 8, null: false
t.string "short_name", limit: 255
t.string "name", limit: 255
t.datetime "created_at"
t.datetime "updated_at"
t.integer "enrollment_term_id", limit: 8, null: false
t.string "workflow_state", null: false, limit: 255
t.text "stuck_sis_fields"
end
add_index "abstract_courses", ["root_account_id", "sis_source_id"], name: "index_abstract_courses_on_root_account_id_and_sis_source_id"
add_index "abstract_courses", ["sis_source_id"], name: "index_abstract_courses_on_sis_source_id"
add_index :abstract_courses, :sis_batch_id, where: "sis_batch_id IS NOT NULL"
add_index :abstract_courses, :enrollment_term_id
create_table :access_tokens do |t|
t.integer :developer_key_id, limit: 8, null: false
t.integer :user_id, limit: 8
t.datetime :last_used_at
t.datetime :expires_at
t.string :purpose, limit: 255
t.timestamps null: true
t.string :crypted_token, limit: 255
t.string :token_hint, limit: 255
t.text :scopes
t.boolean :remember_access
t.string :crypted_refresh_token, limit: 255
end
add_index :access_tokens, [:crypted_token], unique: true
add_index :access_tokens, [:crypted_refresh_token], unique: true
add_index :access_tokens, :user_id
create_table "account_authorization_configs", force: true do |t|
t.integer "account_id", limit: 8, null: false
t.integer "auth_port"
t.string "auth_host", limit: 255
t.string "auth_base", limit: 255
t.string "auth_username", limit: 255
t.string "auth_crypted_password", limit: 255
t.string "auth_password_salt", limit: 255
t.string "auth_type", limit: 255
t.string "auth_over_tls", limit: 255
t.datetime "created_at"
t.datetime "updated_at"
t.string "log_in_url", limit: 255
t.string "log_out_url", limit: 255
t.string "identifier_format", limit: 255
t.text "certificate_fingerprint"
t.string "entity_id", limit: 255
t.text "auth_filter"
t.string "requested_authn_context", limit: 255
t.datetime "last_timeout_failure"
t.text "login_attribute"
t.string "idp_entity_id", limit: 255
t.integer "position"
t.boolean "parent_registration", default: false, null: false
t.string "workflow_state", default: "active", null: false, limit: 255
t.boolean "jit_provisioning", default: false, null: false
t.string "metadata_uri", limit: 255
t.json "settings", default: {}, null: false
end
add_index "account_authorization_configs", ["account_id"], name: "index_account_authorization_configs_on_account_id"
add_index :account_authorization_configs, :workflow_state
add_index :account_authorization_configs, :metadata_uri, where: "metadata_uri IS NOT NULL"
create_table "account_reports" do |t|
t.integer "user_id", limit: 8, null: false
t.text "message"
t.integer "account_id", limit: 8, null: false
t.integer "attachment_id", limit: 8
t.string "workflow_state", default: "created", null: false, limit: 255
t.string "report_type", limit: 255
t.integer "progress"
t.date "start_at"
t.date "end_at"
t.datetime "created_at"
t.datetime "updated_at"
t.text "parameters"
end
add_index :account_reports, :attachment_id
add_index :account_reports, %i[account_id report_type updated_at], order: { updated_at: :desc }, name: "index_account_reports_latest_per_account"
create_table :account_notification_roles do |t|
t.integer :account_notification_id, limit: 8, null: false
t.integer :role_id, limit: 8
end
add_index :account_notification_roles,
[:account_notification_id, :role_id],
unique: true,
name: "index_account_notification_roles_on_role_id"
create_table :account_notifications do |t|
t.string :subject, limit: 255
t.string :icon, default: "warning", limit: 255
t.text :message
t.integer :account_id, limit: 8, null: false
t.integer :user_id, limit: 8
t.datetime :start_at, null: false
t.datetime :end_at, null: false
t.timestamps null: true
t.string :required_account_service, limit: 255
t.integer :months_in_display_cycle
end
add_index :account_notifications, %i[account_id end_at start_at], name: "index_account_notifications_by_account_and_timespan"
create_table "account_users", force: true do |t|
t.integer "account_id", limit: 8, null: false
t.integer "user_id", limit: 8, null: false
t.datetime "created_at"
t.datetime "updated_at"
t.integer "role_id", limit: 8, null: false
end
add_index "account_users", ["account_id"], name: "index_account_users_on_account_id"
add_index "account_users", ["user_id"], name: "index_account_users_on_user_id"
create_table "accounts", force: true do |t|
t.string "name", limit: 255
t.datetime "created_at"
t.datetime "updated_at"
t.string "workflow_state", default: "active", null: false, limit: 255
t.datetime "deleted_at"
t.integer "parent_account_id", limit: 8
t.string "sis_source_id", limit: 255
t.integer "sis_batch_id", limit: 8
t.integer "current_sis_batch_id", limit: 8
t.integer "root_account_id", limit: 8
t.integer "last_successful_sis_batch_id", limit: 8
t.string "membership_types", limit: 255
t.string "default_time_zone", limit: 255
t.string "external_status", default: "active", limit: 255
t.integer "storage_quota", limit: 8
t.integer "default_storage_quota", limit: 8
t.boolean "enable_user_notes", default: false
t.string "allowed_services", limit: 255
t.text "turnitin_pledge"
t.text "turnitin_comments"
t.string "turnitin_account_id", limit: 255
t.string "turnitin_salt", limit: 255
t.string "turnitin_crypted_secret", limit: 255
t.boolean "show_section_name_as_course_name", default: false
t.boolean "allow_sis_import", default: false
t.string "equella_endpoint", limit: 255
t.text "settings"
t.string "uuid", limit: 255
t.string "default_locale", limit: 255
t.text "stuck_sis_fields"
t.bigint "default_user_storage_quota"
t.string "lti_guid", limit: 255
t.bigint "default_group_storage_quota"
t.string "turnitin_host", limit: 255
t.string "integration_id", limit: 255
t.string "lti_context_id", limit: 255
t.string "brand_config_md5", limit: 32
t.string "turnitin_originality", limit: 255
end
add_index "accounts", ["name", "parent_account_id"], name: "index_accounts_on_name_and_parent_account_id"
add_index "accounts", ["parent_account_id", "root_account_id"], name: "index_accounts_on_parent_account_id_and_root_account_id"
add_index :accounts, [:sis_source_id, :root_account_id], where: "sis_source_id IS NOT NULL", unique: true
add_index :accounts, :root_account_id
add_index :accounts, [:integration_id, :root_account_id],
unique: true,
name: "index_accounts_on_integration_id",
where: "integration_id IS NOT NULL"
add_index :accounts, :lti_context_id, unique: true
add_index :accounts, :sis_batch_id, where: "sis_batch_id IS NOT NULL"
add_index :accounts, :brand_config_md5, where: "brand_config_md5 IS NOT NULL"
create_table :alerts do |t|
t.integer :context_id, limit: 8, null: false
t.string :context_type, null: false, limit: 255
t.text :recipients, null: false
t.integer :repetition
t.timestamps null: true
end
create_table :alert_criteria do |t|
t.integer :alert_id, limit: 8
t.string :criterion_type, limit: 255
t.float :threshold
end
create_table :appointment_groups do |t|
t.string :title, limit: 255
t.text :description
t.string :location_name, limit: 255
t.string :location_address, limit: 255
t.integer :context_id, limit: 8
t.string :context_type, limit: 255
t.string :context_code, limit: 255
t.integer :sub_context_id, limit: 8
t.string :sub_context_type, limit: 255
t.string :sub_context_code, limit: 255
t.string :workflow_state, null: false, limit: 255
t.datetime :created_at
t.datetime :updated_at
t.datetime :start_at
t.datetime :end_at
t.integer :participants_per_appointment
t.integer :max_appointments_per_participant # nil means no limit
t.integer :min_appointments_per_participant, default: 0
t.string :participant_visibility, limit: 255
end
add_index :appointment_groups, [:context_id]
create_table :appointment_group_contexts do |t|
t.references :appointment_group, limit: 8
t.string :context_code, limit: 255
t.integer :context_id, limit: 8
t.string :context_type, limit: 255
t.timestamps null: true
end
add_index :appointment_group_contexts, :appointment_group_id
create_table :appointment_group_sub_contexts do |t|
t.references :appointment_group, limit: 8
t.integer :sub_context_id, limit: 8
t.string :sub_context_type, limit: 255
t.string :sub_context_code, limit: 255
t.timestamps null: true
end
add_index :appointment_group_sub_contexts, :appointment_group_id
create_table "assessment_question_bank_users", force: true do |t|
t.integer "assessment_question_bank_id", limit: 8, null: false
t.integer "user_id", limit: 8, null: false
t.datetime "created_at"
t.datetime "updated_at"
end
add_index "assessment_question_bank_users", ["assessment_question_bank_id"], name: "assessment_qbu_aqb_id"
add_index "assessment_question_bank_users", ["user_id"], name: "assessment_qbu_u_id"
create_table "assessment_question_banks", force: true do |t|
t.integer "context_id", limit: 8
t.string "context_type", limit: 255
t.text "title"
t.string "workflow_state", null: false, limit: 255
t.datetime "deleted_at"
t.datetime "created_at"
t.datetime "updated_at"
t.string "migration_id", limit: 255
end
add_index "assessment_question_banks", ["context_id", "context_type"], name: "index_on_aqb_on_context_id_and_context_type"
create_table "assessment_questions", force: true do |t|
t.text "name"
t.text "question_data"
t.integer "context_id", limit: 8
t.string "context_type", limit: 255
t.string "workflow_state", limit: 255
t.datetime "created_at"
t.datetime "updated_at"
t.integer "assessment_question_bank_id", limit: 8
t.datetime "deleted_at"
t.string "migration_id", limit: 255
t.integer "position"
end
add_index "assessment_questions", ["assessment_question_bank_id", "position"], name: "question_bank_id_and_position"
create_table "assessment_requests", force: true do |t|
t.integer "rubric_assessment_id", limit: 8
t.integer "user_id", limit: 8, null: false
t.integer "asset_id", limit: 8, null: false
t.string "asset_type", null: false, limit: 255
t.integer "assessor_asset_id", limit: 8, null: false
t.string "assessor_asset_type", null: false, limit: 255
t.string "workflow_state", null: false, limit: 255
t.datetime "created_at"
t.datetime "updated_at"
t.string "uuid", limit: 255
t.integer "rubric_association_id", limit: 8
t.integer "assessor_id", limit: 8, null: false
end
add_index "assessment_requests", ["assessor_asset_id", "assessor_asset_type"], name: "aa_id_and_aa_type"
add_index "assessment_requests", ["assessor_id"], name: "index_assessment_requests_on_assessor_id"
add_index "assessment_requests", ["asset_id", "asset_type"], name: "index_assessment_requests_on_asset_id_and_asset_type"
add_index "assessment_requests", ["rubric_assessment_id"], name: "index_assessment_requests_on_rubric_assessment_id"
add_index "assessment_requests", ["rubric_association_id"], name: "index_assessment_requests_on_rubric_association_id"
add_index "assessment_requests", ["user_id"], name: "index_assessment_requests_on_user_id"
create_table "asset_user_accesses", force: true do |t|
t.string "asset_code", limit: 255
t.string "asset_group_code", limit: 255
t.integer "user_id", limit: 8
t.integer "context_id", limit: 8
t.string "context_type", limit: 255
t.datetime "last_access"
t.datetime "created_at"
t.datetime "updated_at"
t.string "asset_category", limit: 255
t.float "view_score"
t.float "participate_score"
t.string "action_level", limit: 255
t.text "display_name"
t.string "membership_type", limit: 255
end
add_index "asset_user_accesses", ["user_id", "asset_code"], name: "index_asset_user_accesses_on_user_id_and_asset_code"
add_index :asset_user_accesses, %i[context_id context_type user_id updated_at], name: "index_asset_user_accesses_on_ci_ct_ui_ua"
create_table :assignment_configuration_tool_lookups do |t|
t.integer :assignment_id, limit: 8, null: false
t.integer :tool_id, limit: 8, null: false
t.string :tool_type, null: false, limit: 255
end
add_index :assignment_configuration_tool_lookups, %i[tool_id tool_type assignment_id], unique: true, name: "index_tool_lookup_on_tool_assignment_id"
add_index :assignment_configuration_tool_lookups, :assignment_id
create_table "assignment_groups", force: true do |t|
t.string "name", limit: 255
t.text "rules"
t.string "default_assignment_name", limit: 255
t.integer "position"
t.string "assignment_weighting_scheme", limit: 255
t.float "group_weight"
t.integer "context_id", limit: 8, null: false
t.string "context_type", null: false, limit: 255
t.string "workflow_state", null: false, limit: 255
t.datetime "created_at"
t.datetime "updated_at"
t.integer "cloned_item_id", limit: 8
t.string "context_code", limit: 255
t.string "migration_id", limit: 255
t.string "sis_source_id", limit: 255
t.text "integration_data"
end
add_index "assignment_groups", ["context_id", "context_type"], name: "index_assignment_groups_on_context_id_and_context_type"
create_table :assignment_override_students do |t|
t.timestamps null: true
t.integer :assignment_id, limit: 8
t.integer :assignment_override_id, null: false, limit: 8
t.integer :user_id, null: false, limit: 8
t.integer :quiz_id, limit: 8
end
add_index :assignment_override_students, [:assignment_id, :user_id], unique: true
add_index :assignment_override_students, :assignment_override_id
add_index :assignment_override_students, :user_id
add_index :assignment_override_students, :quiz_id
create_table :assignment_overrides do |t|
t.timestamps null: true
# generic info
t.integer :assignment_id, limit: 8
t.integer :assignment_version
t.string :set_type, null: true, limit: 255
t.integer :set_id, limit: 8
t.string :title, null: false, limit: 255
t.string :workflow_state, null: false, limit: 255
# due at override
t.boolean :due_at_overridden, default: false, null: false
t.datetime :due_at
t.boolean :all_day
t.date :all_day_date
# unlock at override
t.boolean :unlock_at_overridden, default: false, null: false
t.datetime :unlock_at
# lock at override
t.boolean :lock_at_overridden, default: false, null: false
t.datetime :lock_at
t.integer :quiz_id, limit: 8
t.integer :quiz_version
end
add_index :assignment_overrides, %i[assignment_id set_type set_id],
name: "index_assignment_overrides_on_assignment_and_set",
unique: true,
where: "workflow_state='active' and set_id is not null"
add_index :assignment_overrides, [:set_type, :set_id]
add_index :assignment_overrides, :quiz_id
add_index :assignment_overrides, :assignment_id
create_table "assignments", force: true do |t|
t.string "title", limit: 255
t.text "description", limit: 16_777_215
t.datetime "due_at"
t.datetime "unlock_at"
t.datetime "lock_at"
t.float "points_possible"
t.float "min_score"
t.float "max_score"
t.float "mastery_score"
t.string "grading_type", limit: 255
t.string "submission_types", limit: 255
t.string "workflow_state", null: false, limit: 255
t.integer "context_id", limit: 8, null: false
t.string "context_type", null: false, limit: 255
t.integer "assignment_group_id", limit: 8
t.integer "grading_standard_id", limit: 8
t.datetime "created_at"
t.datetime "updated_at"
t.string "group_category", limit: 255
t.integer "submissions_downloads", default: 0
t.integer "peer_review_count", default: 0
t.datetime "peer_reviews_due_at"
t.boolean "peer_reviews_assigned", default: false
t.boolean "peer_reviews", default: false
t.boolean "automatic_peer_reviews", default: false
t.boolean "all_day"
t.date "all_day_date"
t.boolean "could_be_locked"
t.integer "cloned_item_id", limit: 8
t.string "context_code", limit: 255
t.integer "position"
t.string "migration_id", limit: 255
t.boolean "grade_group_students_individually"
t.boolean "anonymous_peer_reviews"
t.string "time_zone_edited", limit: 255
t.boolean "turnitin_enabled"
t.string "allowed_extensions", limit: 255
t.text "turnitin_settings"
t.boolean "muted", default: false
t.integer "group_category_id", limit: 8
t.boolean "freeze_on_copy"
t.boolean "copied"
t.boolean "only_visible_to_overrides"
t.boolean "post_to_sis"
t.string "integration_id", limit: 255
t.text "integration_data"
t.integer "turnitin_id", limit: 8
t.boolean "moderated_grading"
t.datetime "grades_published_at"
t.boolean "omit_from_final_grade"
t.boolean "vericite_enabled"
t.boolean "intra_group_peer_reviews", default: false
t.string "lti_context_id"
end
add_index "assignments", ["assignment_group_id"], name: "index_assignments_on_assignment_group_id"
add_index "assignments", ["context_code"], name: "index_assignments_on_context_code"
add_index "assignments", ["context_id", "context_type"], name: "index_assignments_on_context_id_and_context_type"
add_index "assignments", ["due_at", "context_code"], name: "index_assignments_on_due_at_and_context_code"
add_index "assignments", ["grading_standard_id"], name: "index_assignments_on_grading_standard_id"
add_index :assignments, :turnitin_id, unique: true, where: "turnitin_id IS NOT NULL"
add_index :assignments, :lti_context_id, unique: true
create_table "attachment_associations", force: true do |t|
t.integer "attachment_id", limit: 8
t.integer "context_id", limit: 8
t.string "context_type", limit: 255
end
add_index "attachment_associations", ["attachment_id"], name: "index_attachment_associations_on_attachment_id"
add_index "attachment_associations", ["context_id", "context_type"], name: "attachment_associations_a_id_a_type"
create_table "attachments", force: true do |t|
t.integer "context_id", limit: 8
t.string "context_type", limit: 255
t.integer "size", limit: 8
t.integer "folder_id", limit: 8
t.string "content_type", limit: 255
t.text "filename"
t.string "uuid", limit: 255
t.text "display_name"
t.datetime "created_at"
t.datetime "updated_at"
t.string "workflow_state", limit: 255
t.integer "user_id", limit: 8
t.boolean "locked", default: false
t.string "file_state", limit: 255
t.datetime "deleted_at"
t.integer "position"
t.datetime "lock_at"
t.datetime "unlock_at"
t.datetime "last_lock_at"
t.datetime "last_unlock_at"
t.boolean "could_be_locked"
t.integer "root_attachment_id", limit: 8
t.integer "cloned_item_id", limit: 8
t.string "migration_id", limit: 255
t.string "namespace", limit: 255
t.string "media_entry_id", limit: 255
t.string "md5", limit: 255
t.string "encoding", limit: 255
t.boolean "need_notify"
t.string "upload_error_message", limit: 255
t.integer "replacement_attachment_id", limit: 8
t.integer "usage_rights_id", limit: 8
t.datetime "modified_at"
t.timestamp "viewed_at"
end
add_index "attachments", ["cloned_item_id"], name: "index_attachments_on_cloned_item_id"
add_index "attachments", ["context_id", "context_type"], name: "index_attachments_on_context_id_and_context_type"
add_index "attachments", ["md5", "namespace"], name: "index_attachments_on_md5_and_namespace"
add_index "attachments", ["user_id"], name: "index_attachments_on_user_id"
add_index "attachments", ["workflow_state", "updated_at"], name: "index_attachments_on_workflow_state_and_updated_at"
execute %{create index index_attachments_on_root_attachment_id_not_null on #{Attachment.quoted_table_name} (root_attachment_id) where root_attachment_id is not null}
if (collkey = connection.extension(:pg_collkey)&.schema)
execute("CREATE INDEX index_attachments_on_folder_id_and_file_state_and_display_name ON #{Attachment.quoted_table_name} (folder_id, file_state, #{collkey}.collkey(display_name, 'root', false, 0, true)) WHERE folder_id IS NOT NULL")
else
execute("CREATE INDEX index_attachments_on_folder_id_and_file_state_and_display_name ON #{Attachment.quoted_table_name} (folder_id, file_state, CAST(LOWER(replace(display_name, '\\', '\\\\')) AS bytea)) WHERE folder_id IS NOT NULL")
end
add_index :attachments, %i[folder_id file_state position]
add_index :attachments, :need_notify, where: "need_notify"
add_index :attachments, :replacement_attachment_id, where: "replacement_attachment_id IS NOT NULL"
add_index :attachments, :namespace
add_index :attachments, [:folder_id, :position], where: "folder_id IS NOT NULL"
create_table "calendar_events", force: true do |t|
t.string "title", limit: 255
t.text "description", limit: 16_777_215
t.string "location_name", limit: 255
t.string "location_address", limit: 255
t.datetime "start_at"
t.datetime "end_at"
t.integer "context_id", limit: 8, null: false
t.string "context_type", null: false, limit: 255
t.string "workflow_state", null: false, limit: 255
t.datetime "created_at"
t.datetime "updated_at"
t.integer "user_id", limit: 8
t.boolean "all_day"
t.date "all_day_date"
t.datetime "deleted_at"
t.integer "cloned_item_id", limit: 8
t.string "context_code", limit: 255
t.string "migration_id", limit: 255
t.string "time_zone_edited", limit: 255
t.integer "parent_calendar_event_id", limit: 8
t.string "effective_context_code", limit: 255
t.integer "participants_per_appointment"
t.boolean "override_participants_per_appointment"
t.text "comments"
t.string "timetable_code", limit: 255
end
add_index :calendar_events, %i[context_id context_type timetable_code], where: "timetable_code IS NOT NULL", unique: true, name: "index_calendar_events_on_context_and_timetable_code"
create_table :bookmarks_bookmarks do |t|
t.integer :user_id, limit: 8, null: false
t.string :name, null: false, limit: 255
t.string :url, null: false, limit: 255
t.integer :position
t.text :json
end
add_index :bookmarks_bookmarks, :user_id
create_table :brand_configs, id: false do |t|
t.string :md5, limit: 32, null: false, unique: true
t.column :variables, :text
t.boolean :share, default: false, null: false
t.string :name, limit: 255
t.datetime :created_at, null: false
t.text :js_overrides
t.text :css_overrides
t.text :mobile_js_overrides
t.text :mobile_css_overrides
t.string :parent_md5, limit: 255
end
# because we didn't use the rails default `id` int primary key, we have to add it manually
execute %{ ALTER TABLE #{BrandConfig.quoted_table_name} ADD PRIMARY KEY (md5); }
add_index :brand_configs, :share
add_index "calendar_events", ["context_code"], name: "index_calendar_events_on_context_code"
add_index "calendar_events", ["context_id", "context_type"], name: "index_calendar_events_on_context_id_and_context_type"
add_index "calendar_events", ["user_id"], name: "index_calendar_events_on_user_id"
add_index :calendar_events, [:parent_calendar_event_id]
connection.execute("CREATE INDEX index_calendar_events_on_effective_context_code ON #{CalendarEvent.quoted_table_name}(effective_context_code) WHERE effective_context_code IS NOT NULL")
create_table :canvadocs do |t|
t.string :document_id, limit: 255
t.string :process_state, limit: 255
t.integer :attachment_id, limit: 8, null: false
t.timestamps null: true
t.boolean :has_annotations
t.string :preferred_plugin_course_id, limit: 255
end
add_index :canvadocs, :document_id, unique: true
add_index :canvadocs, :attachment_id
create_table :canvadocs_submissions do |t|
t.integer :canvadoc_id, limit: 8
t.integer :crocodoc_document_id, limit: 8
t.integer :submission_id, limit: 8, null: false
end
add_index :canvadocs_submissions, :submission_id
add_index :canvadocs_submissions, [:submission_id, :canvadoc_id],
where: "canvadoc_id IS NOT NULL",
name: "unique_submissions_and_canvadocs",
unique: true
add_index :canvadocs_submissions, [:submission_id, :crocodoc_document_id],
where: "crocodoc_document_id IS NOT NULL",
name: "unique_submissions_and_crocodocs",
unique: true
add_index :canvadocs_submissions, :crocodoc_document_id,
where: "crocodoc_document_id IS NOT NULL"
create_table "cloned_items", force: true do |t|
t.integer "original_item_id", limit: 8
t.string "original_item_type", limit: 255
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "collaborations", force: true do |t|
t.string "collaboration_type", limit: 255
t.string "document_id", limit: 255
t.integer "user_id", limit: 8
t.integer "context_id", limit: 8
t.string "context_type", limit: 255
t.string "url", limit: 255
t.string "uuid", limit: 255
t.text "data"
t.datetime "created_at"
t.datetime "updated_at"
t.text "description"
t.string "title", null: false, limit: 255
t.string "workflow_state", default: "active", null: false, limit: 255
t.datetime "deleted_at"
t.string "context_code", limit: 255
t.string "type", limit: 255
end
add_index "collaborations", ["context_id", "context_type"], name: "index_collaborations_on_context_id_and_context_type"
add_index "collaborations", ["user_id"], name: "index_collaborations_on_user_id"
create_table "collaborators", force: true do |t|
t.integer "user_id", limit: 8
t.integer "collaboration_id", limit: 8
t.datetime "created_at"
t.datetime "updated_at"
t.string "authorized_service_user_id", limit: 255
t.integer "group_id", limit: 8
end
add_index "collaborators", ["collaboration_id"], name: "index_collaborators_on_collaboration_id"
add_index "collaborators", ["user_id"], name: "index_collaborators_on_user_id"
add_index :collaborators, [:group_id], name: "index_collaborators_on_group_id"
create_table "communication_channels", force: true do |t|
t.string "path", null: false, limit: 255
t.string "path_type", default: "email", null: false, limit: 255
t.integer "position"
t.integer "user_id", limit: 8, null: false
t.integer "pseudonym_id", limit: 8
t.integer "bounce_count", default: 0
t.string "workflow_state", null: false, limit: 255
t.string "confirmation_code", limit: 255
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "build_pseudonym_on_confirm"
t.datetime "last_bounce_at"
# last_bounce_details was originally intended to have limit: 32768, but
# it was typoed as "length" instead of "limit" so it did not apply
t.text "last_bounce_details"
t.datetime "last_suppression_bounce_at"
t.datetime "last_transient_bounce_at"
# last_transient_bounce_details was originally intended to have limit:
# 32768, but it was typoed as "length" instead of "limit" so it did not apply
t.text "last_transient_bounce_details"
end
add_index "communication_channels", ["pseudonym_id", "position"]
add_index "communication_channels", ["user_id", "position"]
connection.execute("CREATE INDEX index_communication_channels_on_path_and_path_type ON #{CommunicationChannel.quoted_table_name} (LOWER(path), path_type)")
if (trgm = connection.extension(:pg_trgm)&.schema)
add_index :communication_channels, "lower(path) #{trgm}.gist_trgm_ops", name: "index_trgm_communication_channels_path", using: :gist
end
add_index :communication_channels, :confirmation_code
connection.execute("CREATE UNIQUE INDEX index_communication_channels_on_user_id_and_path_and_path_type ON #{CommunicationChannel.quoted_table_name} (user_id, LOWER(path), path_type)")
add_index :communication_channels, :last_bounce_at, where: "bounce_count > 0"
create_table :content_exports do |t|
t.integer :user_id, limit: 8
t.integer :attachment_id, limit: 8
t.string :export_type, limit: 255
t.text :settings
t.float :progress
t.string :workflow_state, null: false, limit: 255
t.timestamps null: true
t.integer :content_migration_id, limit: 8
t.string :context_type, limit: 255
t.integer :context_id, limit: 8
end
add_index :content_exports, :attachment_id
add_index :content_exports, :content_migration_id
create_table "content_migrations", force: true do |t|
t.integer "context_id", limit: 8, null: false
t.integer "user_id", limit: 8
t.string "workflow_state", null: false, limit: 255
t.text "migration_settings"
t.datetime "started_at"
t.datetime "finished_at"
t.datetime "created_at"
t.datetime "updated_at"
t.float "progress"
t.string "context_type", limit: 255
t.integer "attachment_id", limit: 8
t.integer "overview_attachment_id", limit: 8
t.integer "exported_attachment_id", limit: 8
t.integer "source_course_id", limit: 8
t.string "migration_type", limit: 255
end
add_index :content_migrations, :context_id
add_index :content_migrations, :attachment_id, where: "attachment_id IS NOT NULL"
add_index :content_migrations, :exported_attachment_id, where: "exported_attachment_id IS NOT NULL"
add_index :content_migrations, :overview_attachment_id, where: "overview_attachment_id IS NOT NULL"
add_index :content_migrations, :source_course_id, where: "source_course_id IS NOT NULL"
create_table "content_participation_counts" do |t|
t.string "content_type", limit: 255
t.string "context_type", limit: 255
t.integer "context_id", limit: 8
t.integer "user_id", limit: 8
t.integer "unread_count", default: 0
t.timestamps null: true
end
add_index "content_participation_counts", %w[context_id context_type user_id content_type], name: "index_content_participation_counts_uniquely", unique: true
create_table "content_participations" do |t|
t.string "content_type", null: false, limit: 255
t.integer "content_id", limit: 8, null: false
t.integer "user_id", limit: 8, null: false
t.string "workflow_state", null: false, limit: 255
end
add_index "content_participations", %w[content_id content_type user_id], name: "index_content_participations_uniquely", unique: true
create_table "content_tags", force: true do |t|
t.integer "content_id", limit: 8
t.string "content_type", limit: 255
t.integer "context_id", limit: 8, null: false
t.string "context_type", null: false, limit: 255
t.text "title"
t.string "tag", limit: 255
t.text "url"
t.datetime "created_at"
t.datetime "updated_at"
t.text "comments"
t.string "tag_type", default: "default", limit: 255
t.integer "context_module_id", limit: 8
t.integer "position"
t.integer "indent"
t.string "migration_id", limit: 255
t.integer "learning_outcome_id", limit: 8
t.string "context_code", limit: 255
t.float "mastery_score"
t.integer "rubric_association_id", limit: 8
t.string "workflow_state", default: "active", null: false, limit: 255
t.integer "cloned_item_id", limit: 8
t.integer "associated_asset_id", limit: 8
t.string "associated_asset_type", limit: 255
t.boolean "new_tab"
end
add_index "content_tags", ["content_id", "content_type"], name: "index_content_tags_on_content_id_and_content_type"
add_index "content_tags", ["context_id", "context_type"], name: "index_content_tags_on_context_id_and_context_type"
add_index "content_tags", ["context_module_id"], name: "index_content_tags_on_context_module_id"
add_index :content_tags, [:associated_asset_id, :associated_asset_type], name: "index_content_tags_on_associated_asset"
add_index :content_tags, :learning_outcome_id, where: "learning_outcome_id IS NOT NULL"
create_table :context_external_tool_assignment_lookups do |t|
t.integer :assignment_id, limit: 8, null: false
t.integer :context_external_tool_id, limit: 8, null: false
end
add_index :context_external_tool_assignment_lookups, [:context_external_tool_id, :assignment_id], unique: true, name: "tool_to_assign"
add_index :context_external_tool_assignment_lookups, :assignment_id
create_table :context_external_tool_placements do |t|
t.string :placement_type, limit: 255
t.integer :context_external_tool_id, limit: 8, null: false
end
add_index :context_external_tool_placements, :context_external_tool_id, name: "external_tool_placements_tool_id"
add_index :context_external_tool_placements, [:placement_type, :context_external_tool_id], unique: true, name: "external_tool_placements_type_and_tool_id"
create_table :context_external_tools do |t|
t.integer :context_id, limit: 8
t.string :context_type, limit: 255
t.string :domain, limit: 255
t.string :url, limit: 4.kilobytes
t.text :shared_secret, null: false
t.text :consumer_key, null: false
t.string :name, null: false, limit: 255
t.text :description
t.text :settings
t.string :workflow_state, null: false, limit: 255
t.timestamps null: true
t.string :migration_id, limit: 255
t.integer :cloned_item_id, limit: 8
t.string :tool_id, limit: 255
t.boolean :not_selectable
t.string :app_center_id, limit: 255
end
add_index :context_external_tools, [:tool_id]
add_index :context_external_tools, [:context_id, :context_type]
add_index :context_external_tools, %i[context_id context_type migration_id], where: "migration_id IS NOT NULL", name: "index_external_tools_on_context_and_migration_id"
create_table "context_module_progressions", force: true do |t|
t.integer "context_module_id", limit: 8
t.integer "user_id", limit: 8
t.text "requirements_met"
t.string "workflow_state", null: false, limit: 255
t.datetime "created_at"
t.datetime "updated_at"
t.boolean "collapsed"
t.integer "current_position"
t.datetime "completed_at"
t.boolean "current"
t.integer "lock_version", default: 0, null: false
t.datetime "evaluated_at"
t.text "incomplete_requirements"
end
add_index "context_module_progressions", ["context_module_id"], name: "index_context_module_progressions_on_context_module_id"
add_index :context_module_progressions, [:user_id, :context_module_id], unique: true, name: "index_cmp_on_user_id_and_module_id"
create_table "context_modules", force: true do |t|
t.integer "context_id", limit: 8, null: false
t.string "context_type", null: false, limit: 255
t.text "name"
t.integer "position"
t.text "prerequisites"
t.text "completion_requirements"
t.datetime "created_at"
t.datetime "updated_at"
t.string "workflow_state", default: "active", null: false, limit: 255
t.datetime "deleted_at"
t.datetime "unlock_at"
t.string "migration_id", limit: 255
t.boolean "require_sequential_progress"
t.integer "cloned_item_id", limit: 8
t.text "completion_events"
t.integer "requirement_count"
end
add_index "context_modules", ["context_id", "context_type"], name: "index_context_modules_on_context_id_and_context_type"
create_table "conversations" do |t|
t.string "private_hash", limit: 255 # for quick lookups so we know whether or not we need to create a new one
t.boolean "has_attachments", default: false, null: false
t.boolean "has_media_objects", default: false, null: false
t.text "tags"
t.text "root_account_ids"
t.string "subject", limit: 255
t.string "context_type", limit: 255
t.integer "context_id", limit: 8
t.timestamp "updated_at"
end
add_index "conversations", ["private_hash"], unique: true
create_table :conversation_batches do |t|
t.string :workflow_state, null: false, limit: 255
t.integer :user_id, limit: 8, null: false
t.text :recipient_ids
t.integer :root_conversation_message_id, limit: 8, null: false
t.text :conversation_message_ids
t.text :tags
t.timestamps null: true
t.string "context_type", limit: 255
t.integer "context_id", limit: 8
t.string :subject, limit: 255
t.boolean :group
t.boolean :generate_user_note
end
add_index :conversation_batches, [:user_id, :workflow_state]
create_table "conversation_participants" do |t|
t.integer "conversation_id", limit: 8, null: false
t.integer "user_id", limit: 8, null: false
t.datetime "last_message_at"
t.boolean "subscribed", default: true
t.string "workflow_state", null: false, limit: 255
t.datetime "last_authored_at"
t.boolean "has_attachments", default: false, null: false
t.boolean "has_media_objects", default: false, null: false
t.integer "message_count", default: 0
t.string "label", limit: 255
t.text "tags"
t.datetime "visible_last_authored_at"
t.text "root_account_ids"
t.string "private_hash", limit: 255
t.timestamp "updated_at"
end
add_index "conversation_participants", ["user_id", "last_message_at"]
add_index :conversation_participants, [:conversation_id, :user_id], unique: true
add_index :conversation_participants, [:private_hash, :user_id], where: "private_hash IS NOT NULL", unique: true
create_table "conversation_messages" do |t|
t.integer "conversation_id", limit: 8
t.integer "author_id", limit: 8
t.datetime "created_at"
t.boolean "generated"
t.text "body"
t.text "forwarded_message_ids"
t.string "media_comment_id", limit: 255
t.string "media_comment_type", limit: 255
t.integer "context_id", limit: 8
t.string "context_type", limit: 255
t.integer "asset_id", limit: 8
t.string "asset_type", limit: 255
t.text "attachment_ids"
t.boolean "has_attachments"
t.boolean "has_media_objects"
end
add_index "conversation_messages", ["conversation_id", "created_at"]
add_index :conversation_messages, :author_id
create_table "conversation_message_participants" do |t|
t.integer "conversation_message_id", limit: 8
t.integer "conversation_participant_id", limit: 8
t.text "tags"
t.integer "user_id", limit: 8
t.string "workflow_state", limit: 255
t.datetime "deleted_at"
end
add_index :conversation_message_participants, [:conversation_participant_id, :conversation_message_id], name: :index_cmp_on_cpi_and_cmi
add_index :conversation_message_participants, [:user_id, :conversation_message_id], name: "index_conversation_message_participants_on_uid_and_message_id", unique: true
add_index :conversation_message_participants, :conversation_message_id, name: "index_conversation_message_participants_on_message_id"
add_index :conversation_message_participants, :deleted_at
create_table "course_account_associations", force: true do |t|
t.integer "course_id", limit: 8, null: false
t.integer "account_id", limit: 8, null: false
t.integer "depth", null: false
t.datetime "created_at"
t.datetime "updated_at"
t.integer "course_section_id", limit: 8
end
add_index "course_account_associations", ["account_id", "depth"], name: "index_course_account_associations_on_account_id_and_depth_id"
add_index :course_account_associations, %i[course_id course_section_id account_id], unique: true, name: "index_caa_on_course_id_and_section_id_and_account_id"
add_index :course_account_associations, :course_section_id
create_table "course_sections", force: true do |t|
t.string "sis_source_id", limit: 255
t.integer "sis_batch_id", limit: 8