Spaces:
Paused
Paused
Nambinintsoa Rovatiana RAMAROSON commited on
Commit ·
7cd4ee8
1
Parent(s): 429fd47
fixing storage missing field supabase
Browse files- Dockerfile +2 -2
- config/database.yml +1 -0
- config/environments/development.rb +6 -1
- db/schema.rb +352 -0
- lib/tasks/active_storage_reupload.rake +25 -0
- lib/tasks/migrate_active_storage.rake +41 -0
Dockerfile
CHANGED
|
@@ -163,8 +163,8 @@ ENV SUPABASE_ENDPOINT="https://kppzvlhfxgwhezcwjrdi.storage.supabase.co/storage/
|
|
| 163 |
# Créer les répertoires manquants
|
| 164 |
RUN mkdir -p tmp/pids log
|
| 165 |
|
| 166 |
-
#
|
| 167 |
-
|
| 168 |
|
| 169 |
# Use Tini.
|
| 170 |
ENTRYPOINT ["/tini", "--"]
|
|
|
|
| 163 |
# Créer les répertoires manquants
|
| 164 |
RUN mkdir -p tmp/pids log
|
| 165 |
|
| 166 |
+
# Définir PORT par défaut pour local
|
| 167 |
+
ENV PORT=7860
|
| 168 |
|
| 169 |
# Use Tini.
|
| 170 |
ENTRYPOINT ["/tini", "--"]
|
config/database.yml
CHANGED
|
@@ -7,6 +7,7 @@ common: &common
|
|
| 7 |
username: <%= ENV['DB_USER'] %>
|
| 8 |
password: "<%= ENV['DB_PASSWORD'] %>"
|
| 9 |
sslmode: require
|
|
|
|
| 10 |
|
| 11 |
development:
|
| 12 |
<<: *common
|
|
|
|
| 7 |
username: <%= ENV['DB_USER'] %>
|
| 8 |
password: "<%= ENV['DB_PASSWORD'] %>"
|
| 9 |
sslmode: require
|
| 10 |
+
prepared_statements: false
|
| 11 |
|
| 12 |
development:
|
| 13 |
<<: *common
|
config/environments/development.rb
CHANGED
|
@@ -38,7 +38,12 @@ Rails.application.configure do
|
|
| 38 |
end
|
| 39 |
|
| 40 |
# Store uploaded files on the local file system (see config/storage.yml for options).
|
| 41 |
-
config.active_storage.service = :local
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
# Don't care if the mailer can't send.
|
| 44 |
config.action_mailer.raise_delivery_errors = false
|
|
|
|
| 38 |
end
|
| 39 |
|
| 40 |
# Store uploaded files on the local file system (see config/storage.yml for options).
|
| 41 |
+
# config.active_storage.service = :local
|
| 42 |
+
config.active_storage.service = :supabase
|
| 43 |
+
|
| 44 |
+
# Désactive strict CSP en dev
|
| 45 |
+
config.action_dispatch.default_headers.delete('Content-Security-Policy')
|
| 46 |
+
|
| 47 |
|
| 48 |
# Don't care if the mailer can't send.
|
| 49 |
config.action_mailer.raise_delivery_errors = false
|
db/schema.rb
CHANGED
|
@@ -357,3 +357,355 @@ ActiveRecord::Schema[7.1].define(version: 2024_08_07_110658) do
|
|
| 357 |
t.index ["priority", "run_at"], name: "delayed_jobs_priority"
|
| 358 |
end
|
| 359 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 357 |
t.index ["priority", "run_at"], name: "delayed_jobs_priority"
|
| 358 |
end
|
| 359 |
|
| 360 |
+
create_table "discord_messages", force: :cascade do |t|
|
| 361 |
+
t.string "author_uuid", null: false
|
| 362 |
+
t.string "channel_uuid"
|
| 363 |
+
t.string "message_uuid", null: false
|
| 364 |
+
t.string "server_uuid", null: false
|
| 365 |
+
t.string "content"
|
| 366 |
+
t.datetime "timestamp", precision: nil
|
| 367 |
+
t.bigint "user_id", null: false
|
| 368 |
+
t.datetime "created_at", null: false
|
| 369 |
+
t.datetime "updated_at", null: false
|
| 370 |
+
t.index ["author_uuid"], name: "index_discord_messages_on_author_uuid"
|
| 371 |
+
t.index ["channel_uuid"], name: "index_discord_messages_on_channel_uuid"
|
| 372 |
+
t.index ["server_uuid"], name: "index_discord_messages_on_server_uuid"
|
| 373 |
+
t.index ["user_id"], name: "index_discord_messages_on_user_id"
|
| 374 |
+
end
|
| 375 |
+
|
| 376 |
+
create_table "discord_roles", force: :cascade do |t|
|
| 377 |
+
t.string "name"
|
| 378 |
+
t.string "discord_id", null: false
|
| 379 |
+
t.bigint "school_id", null: false
|
| 380 |
+
t.integer "position"
|
| 381 |
+
t.string "color_hex"
|
| 382 |
+
t.boolean "default", default: false
|
| 383 |
+
t.jsonb "data"
|
| 384 |
+
t.datetime "created_at", null: false
|
| 385 |
+
t.datetime "updated_at", null: false
|
| 386 |
+
t.index ["discord_id"], name: "index_discord_roles_on_discord_id", unique: true
|
| 387 |
+
t.index ["school_id"], name: "index_discord_roles_on_school_id"
|
| 388 |
+
end
|
| 389 |
+
|
| 390 |
+
create_table "domains", force: :cascade do |t|
|
| 391 |
+
t.bigint "school_id"
|
| 392 |
+
t.string "fqdn"
|
| 393 |
+
t.datetime "created_at", precision: nil, null: false
|
| 394 |
+
t.datetime "updated_at", precision: nil, null: false
|
| 395 |
+
t.boolean "primary", default: false
|
| 396 |
+
t.index ["fqdn"], name: "index_domains_on_fqdn", unique: true
|
| 397 |
+
t.index ["school_id"], name: "index_domains_on_school_id"
|
| 398 |
+
end
|
| 399 |
+
|
| 400 |
+
create_table "evaluation_criteria", force: :cascade do |t|
|
| 401 |
+
t.datetime "created_at", precision: nil, null: false
|
| 402 |
+
t.datetime "updated_at", precision: nil, null: false
|
| 403 |
+
t.string "name"
|
| 404 |
+
t.bigint "course_id"
|
| 405 |
+
t.integer "max_grade"
|
| 406 |
+
t.jsonb "grade_labels"
|
| 407 |
+
t.index ["course_id"], name: "index_evaluation_criteria_on_course_id"
|
| 408 |
+
end
|
| 409 |
+
|
| 410 |
+
create_table "faculty", force: :cascade do |t|
|
| 411 |
+
t.string "category"
|
| 412 |
+
t.integer "sort_index"
|
| 413 |
+
t.datetime "created_at", null: false
|
| 414 |
+
t.datetime "updated_at", null: false
|
| 415 |
+
t.string "token"
|
| 416 |
+
t.string "current_commitment"
|
| 417 |
+
t.string "commitment"
|
| 418 |
+
t.string "compensation"
|
| 419 |
+
t.bigint "user_id"
|
| 420 |
+
t.boolean "public", default: false
|
| 421 |
+
t.string "connect_link"
|
| 422 |
+
t.boolean "notify_for_submission", default: false
|
| 423 |
+
t.boolean "exited", default: false
|
| 424 |
+
t.index ["category"], name: "index_faculty_on_category"
|
| 425 |
+
t.index ["user_id"], name: "index_faculty_on_user_id"
|
| 426 |
+
end
|
| 427 |
+
|
| 428 |
+
create_table "faculty_cohort_enrollments", force: :cascade do |t|
|
| 429 |
+
t.bigint "faculty_id"
|
| 430 |
+
t.bigint "cohort_id"
|
| 431 |
+
t.datetime "created_at", null: false
|
| 432 |
+
t.datetime "updated_at", null: false
|
| 433 |
+
t.index ["cohort_id", "faculty_id"], name: "index_faculty_cohort_enrollments_on_cohort_id_and_faculty_id", unique: true
|
| 434 |
+
t.index ["faculty_id"], name: "index_faculty_cohort_enrollments_on_faculty_id"
|
| 435 |
+
end
|
| 436 |
+
|
| 437 |
+
create_table "faculty_student_enrollments", force: :cascade do |t|
|
| 438 |
+
t.bigint "faculty_id"
|
| 439 |
+
t.datetime "created_at", null: false
|
| 440 |
+
t.datetime "updated_at", null: false
|
| 441 |
+
t.bigint "student_id"
|
| 442 |
+
t.index ["faculty_id", "student_id"], name: "index_faculty_student_enrollments_on_faculty_id_and_student_id", unique: true
|
| 443 |
+
t.index ["faculty_id"], name: "index_faculty_student_enrollments_on_faculty_id"
|
| 444 |
+
t.index ["student_id"], name: "index_faculty_student_enrollments_on_student_id"
|
| 445 |
+
end
|
| 446 |
+
|
| 447 |
+
create_table "failed_input_token_attempts", force: :cascade do |t|
|
| 448 |
+
t.string "authenticatable_type", null: false
|
| 449 |
+
t.bigint "authenticatable_id", null: false
|
| 450 |
+
t.string "purpose", null: false
|
| 451 |
+
t.datetime "created_at", null: false
|
| 452 |
+
t.datetime "updated_at", null: false
|
| 453 |
+
t.index ["authenticatable_type", "authenticatable_id", "purpose"], name: "index_failed_attempts_on_authenticatable_and_purpose"
|
| 454 |
+
t.index ["authenticatable_type", "authenticatable_id"], name: "index_failed_input_token_attempts_on_authenticatable"
|
| 455 |
+
end
|
| 456 |
+
|
| 457 |
+
create_table "features", force: :cascade do |t|
|
| 458 |
+
t.string "key"
|
| 459 |
+
t.string "value"
|
| 460 |
+
t.datetime "created_at", null: false
|
| 461 |
+
t.datetime "updated_at", null: false
|
| 462 |
+
end
|
| 463 |
+
|
| 464 |
+
create_table "flipper_features", force: :cascade do |t|
|
| 465 |
+
t.string "key", null: false
|
| 466 |
+
t.datetime "created_at", null: false
|
| 467 |
+
t.datetime "updated_at", null: false
|
| 468 |
+
t.index ["key"], name: "index_flipper_features_on_key", unique: true
|
| 469 |
+
end
|
| 470 |
+
|
| 471 |
+
create_table "flipper_gates", force: :cascade do |t|
|
| 472 |
+
t.string "feature_key", null: false
|
| 473 |
+
t.string "key", null: false
|
| 474 |
+
t.string "value"
|
| 475 |
+
t.datetime "created_at", null: false
|
| 476 |
+
t.datetime "updated_at", null: false
|
| 477 |
+
t.index ["feature_key", "key", "value"], name: "index_flipper_gates_on_feature_key_and_key_and_value", unique: true
|
| 478 |
+
end
|
| 479 |
+
|
| 480 |
+
create_table "inbound_webhooks", force: :cascade do |t|
|
| 481 |
+
t.string "status", default: "pending", null: false
|
| 482 |
+
t.text "body"
|
| 483 |
+
t.datetime "created_at", null: false
|
| 484 |
+
t.datetime "updated_at", null: false
|
| 485 |
+
end
|
| 486 |
+
|
| 487 |
+
create_table "issued_certificates", force: :cascade do |t|
|
| 488 |
+
t.bigint "certificate_id", null: false
|
| 489 |
+
t.bigint "user_id"
|
| 490 |
+
t.string "name", null: false
|
| 491 |
+
t.citext "serial_number", null: false
|
| 492 |
+
t.datetime "created_at", null: false
|
| 493 |
+
t.datetime "updated_at", null: false
|
| 494 |
+
t.bigint "issuer_id"
|
| 495 |
+
t.bigint "revoker_id"
|
| 496 |
+
t.datetime "revoked_at", precision: nil
|
| 497 |
+
t.index ["certificate_id"], name: "index_issued_certificates_on_certificate_id"
|
| 498 |
+
t.index ["issuer_id"], name: "index_issued_certificates_on_issuer_id"
|
| 499 |
+
t.index ["revoker_id"], name: "index_issued_certificates_on_revoker_id"
|
| 500 |
+
t.index ["serial_number"], name: "index_issued_certificates_on_serial_number", unique: true
|
| 501 |
+
t.index ["user_id"], name: "index_issued_certificates_on_user_id"
|
| 502 |
+
end
|
| 503 |
+
|
| 504 |
+
create_table "leaderboard_entries", force: :cascade do |t|
|
| 505 |
+
t.datetime "period_from", precision: nil, null: false
|
| 506 |
+
t.datetime "period_to", precision: nil, null: false
|
| 507 |
+
t.integer "score", null: false
|
| 508 |
+
t.datetime "created_at", precision: nil, null: false
|
| 509 |
+
t.datetime "updated_at", precision: nil, null: false
|
| 510 |
+
t.bigint "student_id"
|
| 511 |
+
t.index ["student_id", "period_from", "period_to"], name: "index_leaderboard_on_student_id_and_period_from_and_to", unique: true
|
| 512 |
+
t.index ["student_id"], name: "index_leaderboard_entries_on_student_id"
|
| 513 |
+
end
|
| 514 |
+
|
| 515 |
+
create_table "levels", id: :serial, force: :cascade do |t|
|
| 516 |
+
t.string "name"
|
| 517 |
+
t.text "description"
|
| 518 |
+
t.integer "number"
|
| 519 |
+
t.datetime "created_at", precision: nil, null: false
|
| 520 |
+
t.datetime "updated_at", precision: nil, null: false
|
| 521 |
+
t.datetime "unlock_at", precision: nil
|
| 522 |
+
t.bigint "course_id"
|
| 523 |
+
t.index ["course_id"], name: "index_levels_on_course_id"
|
| 524 |
+
t.index ["number", "course_id"], name: "index_levels_on_number_and_course_id", unique: true
|
| 525 |
+
end
|
| 526 |
+
|
| 527 |
+
create_table "markdown_attachments", force: :cascade do |t|
|
| 528 |
+
t.string "token"
|
| 529 |
+
t.datetime "last_accessed_at", precision: nil
|
| 530 |
+
t.bigint "user_id"
|
| 531 |
+
t.datetime "created_at", precision: nil, null: false
|
| 532 |
+
t.datetime "updated_at", precision: nil, null: false
|
| 533 |
+
t.bigint "school_id"
|
| 534 |
+
t.index ["school_id"], name: "index_markdown_attachments_on_school_id"
|
| 535 |
+
t.index ["user_id"], name: "index_markdown_attachments_on_user_id"
|
| 536 |
+
end
|
| 537 |
+
|
| 538 |
+
create_table "moderation_reports", force: :cascade do |t|
|
| 539 |
+
t.text "reason"
|
| 540 |
+
t.bigint "user_id", null: false
|
| 541 |
+
t.string "reportable_type", null: false
|
| 542 |
+
t.bigint "reportable_id", null: false
|
| 543 |
+
t.datetime "created_at", null: false
|
| 544 |
+
t.datetime "updated_at", null: false
|
| 545 |
+
t.index ["reportable_type", "reportable_id"], name: "index_moderation_reports_on_reportable"
|
| 546 |
+
t.index ["user_id", "reportable_type", "reportable_id"], name: "index_moderation_reports_on_user_and_reportable", unique: true
|
| 547 |
+
t.index ["user_id"], name: "index_moderation_reports_on_user_id"
|
| 548 |
+
end
|
| 549 |
+
|
| 550 |
+
create_table "notifications", force: :cascade do |t|
|
| 551 |
+
t.bigint "actor_id"
|
| 552 |
+
t.bigint "recipient_id"
|
| 553 |
+
t.string "notifiable_type"
|
| 554 |
+
t.bigint "notifiable_id"
|
| 555 |
+
t.datetime "read_at", precision: nil
|
| 556 |
+
t.text "message"
|
| 557 |
+
t.string "event"
|
| 558 |
+
t.datetime "created_at", null: false
|
| 559 |
+
t.datetime "updated_at", null: false
|
| 560 |
+
t.index ["actor_id"], name: "index_notifications_on_actor_id"
|
| 561 |
+
t.index ["notifiable_type", "notifiable_id"], name: "index_notifications_on_notifiable_type_and_notifiable_id"
|
| 562 |
+
t.index ["recipient_id"], name: "index_notifications_on_recipient_id"
|
| 563 |
+
end
|
| 564 |
+
|
| 565 |
+
create_table "organisation_admins", force: :cascade do |t|
|
| 566 |
+
t.bigint "organisation_id", null: false
|
| 567 |
+
t.bigint "user_id", null: false
|
| 568 |
+
t.datetime "created_at", null: false
|
| 569 |
+
t.datetime "updated_at", null: false
|
| 570 |
+
t.index ["organisation_id"], name: "index_organisation_admins_on_organisation_id"
|
| 571 |
+
t.index ["user_id"], name: "index_organisation_admins_on_user_id"
|
| 572 |
+
end
|
| 573 |
+
|
| 574 |
+
create_table "organisations", force: :cascade do |t|
|
| 575 |
+
t.string "name"
|
| 576 |
+
t.bigint "school_id", null: false
|
| 577 |
+
t.datetime "created_at", null: false
|
| 578 |
+
t.datetime "updated_at", null: false
|
| 579 |
+
t.index ["school_id"], name: "index_organisations_on_school_id"
|
| 580 |
+
end
|
| 581 |
+
|
| 582 |
+
create_table "page_reads", force: :cascade do |t|
|
| 583 |
+
t.bigint "target_id", null: false
|
| 584 |
+
t.bigint "student_id", null: false
|
| 585 |
+
t.datetime "created_at", precision: nil
|
| 586 |
+
t.index ["student_id", "target_id"], name: "index_page_reads_on_student_id_and_target_id", unique: true
|
| 587 |
+
t.index ["student_id"], name: "index_page_reads_on_student_id"
|
| 588 |
+
t.index ["target_id"], name: "index_page_reads_on_target_id"
|
| 589 |
+
end
|
| 590 |
+
|
| 591 |
+
create_table "post_likes", force: :cascade do |t|
|
| 592 |
+
t.bigint "post_id"
|
| 593 |
+
t.bigint "user_id"
|
| 594 |
+
t.datetime "created_at", null: false
|
| 595 |
+
t.datetime "updated_at", null: false
|
| 596 |
+
t.index ["post_id", "user_id"], name: "index_post_likes_on_post_id_and_user_id", unique: true
|
| 597 |
+
t.index ["user_id"], name: "index_post_likes_on_user_id"
|
| 598 |
+
end
|
| 599 |
+
|
| 600 |
+
create_table "posts", force: :cascade do |t|
|
| 601 |
+
t.bigint "topic_id"
|
| 602 |
+
t.bigint "creator_id"
|
| 603 |
+
t.bigint "editor_id"
|
| 604 |
+
t.bigint "archiver_id"
|
| 605 |
+
t.datetime "archived_at", precision: nil
|
| 606 |
+
t.bigint "reply_to_post_id"
|
| 607 |
+
t.integer "post_number", null: false
|
| 608 |
+
t.text "body"
|
| 609 |
+
t.boolean "solution", default: false
|
| 610 |
+
t.datetime "created_at", null: false
|
| 611 |
+
t.datetime "updated_at", null: false
|
| 612 |
+
t.string "edit_reason"
|
| 613 |
+
t.index ["archiver_id"], name: "index_posts_on_archiver_id"
|
| 614 |
+
t.index ["creator_id"], name: "index_posts_on_creator_id"
|
| 615 |
+
t.index ["editor_id"], name: "index_posts_on_editor_id"
|
| 616 |
+
t.index ["post_number", "topic_id"], name: "index_posts_on_post_number_and_topic_id", unique: true
|
| 617 |
+
t.index ["reply_to_post_id"], name: "index_posts_on_reply_to_post_id"
|
| 618 |
+
t.index ["topic_id"], name: "index_posts_on_topic_id"
|
| 619 |
+
end
|
| 620 |
+
|
| 621 |
+
create_table "quiz_questions", force: :cascade do |t|
|
| 622 |
+
t.text "question"
|
| 623 |
+
t.text "description"
|
| 624 |
+
t.bigint "quiz_id"
|
| 625 |
+
t.datetime "created_at", precision: nil, null: false
|
| 626 |
+
t.datetime "updated_at", precision: nil, null: false
|
| 627 |
+
t.bigint "correct_answer_id"
|
| 628 |
+
t.index ["correct_answer_id"], name: "index_quiz_questions_on_correct_answer_id"
|
| 629 |
+
t.index ["quiz_id"], name: "index_quiz_questions_on_quiz_id"
|
| 630 |
+
end
|
| 631 |
+
|
| 632 |
+
create_table "quizzes", force: :cascade do |t|
|
| 633 |
+
t.string "title"
|
| 634 |
+
t.datetime "created_at", precision: nil, null: false
|
| 635 |
+
t.datetime "updated_at", precision: nil, null: false
|
| 636 |
+
t.bigint "assignment_id"
|
| 637 |
+
t.index ["assignment_id"], name: "index_quizzes_on_assignment_id"
|
| 638 |
+
end
|
| 639 |
+
|
| 640 |
+
create_table "reactions", force: :cascade do |t|
|
| 641 |
+
t.string "reaction_value"
|
| 642 |
+
t.bigint "user_id", null: false
|
| 643 |
+
t.string "reactionable_type", null: false
|
| 644 |
+
t.bigint "reactionable_id", null: false
|
| 645 |
+
t.datetime "created_at", null: false
|
| 646 |
+
t.datetime "updated_at", null: false
|
| 647 |
+
t.index ["reactionable_type", "reactionable_id"], name: "index_reactions_on_reactionable"
|
| 648 |
+
t.index ["user_id", "reactionable_type", "reactionable_id", "reaction_value"], name: "index_reactions_on_user_and_reactionable", unique: true
|
| 649 |
+
t.index ["user_id"], name: "index_reactions_on_user_id"
|
| 650 |
+
end
|
| 651 |
+
|
| 652 |
+
create_table "resource_versions", force: :cascade do |t|
|
| 653 |
+
t.jsonb "value"
|
| 654 |
+
t.string "versionable_type"
|
| 655 |
+
t.bigint "versionable_id"
|
| 656 |
+
t.datetime "created_at", null: false
|
| 657 |
+
t.datetime "updated_at", null: false
|
| 658 |
+
t.index ["versionable_type", "versionable_id"], name: "index_resource_versions_on_versionable_type_and_versionable_id"
|
| 659 |
+
end
|
| 660 |
+
|
| 661 |
+
create_table "school_admins", force: :cascade do |t|
|
| 662 |
+
t.bigint "user_id"
|
| 663 |
+
t.datetime "created_at", precision: nil, null: false
|
| 664 |
+
t.datetime "updated_at", precision: nil, null: false
|
| 665 |
+
t.index ["user_id"], name: "index_school_admins_on_user_id", unique: true
|
| 666 |
+
end
|
| 667 |
+
|
| 668 |
+
create_table "school_links", force: :cascade do |t|
|
| 669 |
+
t.bigint "school_id"
|
| 670 |
+
t.string "title"
|
| 671 |
+
t.string "url"
|
| 672 |
+
t.string "kind"
|
| 673 |
+
t.datetime "created_at", precision: nil, null: false
|
| 674 |
+
t.datetime "updated_at", precision: nil, null: false
|
| 675 |
+
t.integer "sort_index", default: 0, null: false
|
| 676 |
+
t.index ["school_id", "kind"], name: "index_school_links_on_school_id_and_kind"
|
| 677 |
+
end
|
| 678 |
+
|
| 679 |
+
create_table "school_strings", force: :cascade do |t|
|
| 680 |
+
t.bigint "school_id"
|
| 681 |
+
t.string "key"
|
| 682 |
+
t.text "value"
|
| 683 |
+
t.datetime "created_at", precision: nil, null: false
|
| 684 |
+
t.datetime "updated_at", precision: nil, null: false
|
| 685 |
+
t.index ["school_id", "key"], name: "index_school_strings_on_school_id_and_key", unique: true
|
| 686 |
+
end
|
| 687 |
+
|
| 688 |
+
create_table "schools", force: :cascade do |t|
|
| 689 |
+
t.string "name"
|
| 690 |
+
t.datetime "created_at", precision: nil, null: false
|
| 691 |
+
t.datetime "updated_at", precision: nil, null: false
|
| 692 |
+
t.text "about"
|
| 693 |
+
t.jsonb "configuration", default: {}, null: false
|
| 694 |
+
t.boolean "beckn_enabled", default: false, null: false
|
| 695 |
+
end
|
| 696 |
+
|
| 697 |
+
create_table "standings", force: :cascade do |t|
|
| 698 |
+
t.string "name"
|
| 699 |
+
t.string "color"
|
| 700 |
+
t.text "description"
|
| 701 |
+
t.boolean "default", default: false, null: false
|
| 702 |
+
t.datetime "archived_at"
|
| 703 |
+
t.bigint "school_id", null: false
|
| 704 |
+
t.datetime "created_at", null: false
|
| 705 |
+
t.datetime "updated_at", null: false
|
| 706 |
+
t.index ["archived_at"], name: "index_standings_on_archived_at"
|
| 707 |
+
t.index ["default"], name: "index_standings_on_default", where: "(\"default\" = true)"
|
| 708 |
+
t.index ["name", "school_id"], name: "index_standings_on_name_and_school_id", unique: true
|
| 709 |
+
t.index ["school_id"], name: "index_standings_on_school_id"
|
| 710 |
+
end
|
| 711 |
+
|
lib/tasks/active_storage_reupload.rake
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# lib/tasks/active_storage_reupload.rake
|
| 2 |
+
namespace :active_storage do
|
| 3 |
+
desc "Reupload all files from local to Supabase"
|
| 4 |
+
task reupload: :environment do
|
| 5 |
+
local_service = ActiveStorage::Blob.services.fetch(:local)
|
| 6 |
+
supabase_service = ActiveStorage::Blob.services.fetch(:supabase)
|
| 7 |
+
|
| 8 |
+
ActiveStorage::Blob.find_each do |blob|
|
| 9 |
+
puts "Reuploading #{blob.filename}..."
|
| 10 |
+
|
| 11 |
+
local_path = local_service.send(:path_for, blob.key)
|
| 12 |
+
puts "local_path #{local_path.inspect}..."
|
| 13 |
+
|
| 14 |
+
if File.exist?(local_path)
|
| 15 |
+
File.open(local_path, 'rb') do |file|
|
| 16 |
+
supabase_service.upload(blob.key, file, checksum: blob.checksum)
|
| 17 |
+
end
|
| 18 |
+
blob.update!(service_name: "supabase")
|
| 19 |
+
puts "✅ #{blob.filename} reuploaded"
|
| 20 |
+
else
|
| 21 |
+
puts "❌ Fichier introuvable: #{blob.filename}"
|
| 22 |
+
end
|
| 23 |
+
end
|
| 24 |
+
end
|
| 25 |
+
end
|
lib/tasks/migrate_active_storage.rake
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
namespace :active_storage do
|
| 2 |
+
desc "Migrer les fichiers d'Active Storage du local vers Supabase"
|
| 3 |
+
task migrate_to_supabase: :environment do
|
| 4 |
+
old_service = ActiveStorage::Blob.service
|
| 5 |
+
new_service = ActiveStorage::Service.configure(:supabase, Rails.configuration.active_storage.service_configurations)
|
| 6 |
+
|
| 7 |
+
total = ActiveStorage::Blob.count
|
| 8 |
+
migrated = 0
|
| 9 |
+
|
| 10 |
+
ActiveStorage::Blob.find_each.with_index(1) do |blob, index|
|
| 11 |
+
puts "[#{index}/#{total}] Migration du blob ##{blob.id} (#{blob.filename})..."
|
| 12 |
+
|
| 13 |
+
begin
|
| 14 |
+
# Vérifier si le fichier existe dans l'ancien service
|
| 15 |
+
unless old_service.exist?(blob.key)
|
| 16 |
+
puts "⚠️ Fichier introuvable pour le blob ##{blob.id} (#{blob.filename}), ignoré."
|
| 17 |
+
next
|
| 18 |
+
end
|
| 19 |
+
|
| 20 |
+
# Vérifier si le fichier existe déjà dans le nouveau service
|
| 21 |
+
if new_service.exist?(blob.key)
|
| 22 |
+
puts "✅ Déjà présent dans Supabase, ignoré."
|
| 23 |
+
next
|
| 24 |
+
end
|
| 25 |
+
|
| 26 |
+
# Migrer le fichier
|
| 27 |
+
old_service.open(blob.key) do |tempfile|
|
| 28 |
+
new_service.upload(blob.key, tempfile, checksum: blob.checksum)
|
| 29 |
+
end
|
| 30 |
+
|
| 31 |
+
migrated += 1
|
| 32 |
+
puts "✔ Migré avec succès."
|
| 33 |
+
rescue => e
|
| 34 |
+
puts "❌ Erreur lors de la migration du blob ##{blob.id}: #{e.message}"
|
| 35 |
+
next
|
| 36 |
+
end
|
| 37 |
+
end
|
| 38 |
+
|
| 39 |
+
puts "✅ Migration terminée. #{migrated} blobs migrés sur #{total}."
|
| 40 |
+
end
|
| 41 |
+
end
|