|
10 | 10 | #
|
11 | 11 | # It's strongly recommended that you check this file into your version control system.
|
12 | 12 |
|
13 |
| -ActiveRecord::Schema[7.0].define(version: 2022_09_25_225117) do |
| 13 | +ActiveRecord::Schema[7.0].define(version: 2022_09_26_010740) do |
14 | 14 | # These are extensions that must be enabled in order to support this database
|
15 | 15 | enable_extension "plpgsql"
|
16 | 16 |
|
|
320 | 320 | add_index "unified_restrictions", ["restriction_id"], name: "index_unified_restrictions_on_restriction_id"
|
321 | 321 | add_index "unified_restrictions", ["snapshot_id"], name: "index_unified_restrictions_on_snapshot_id"
|
322 | 322 |
|
| 323 | + create_view "unified_cards", materialized: true, sql_definition: <<-SQL |
| 324 | + WITH card_cycles_summary AS ( |
| 325 | + SELECT c_1.id, |
| 326 | + array_agg(cc.id ORDER BY cc.id) AS card_cycle_ids, |
| 327 | + array_agg(lower(cc.name) ORDER BY (lower(cc.name))) AS card_cycle_names |
| 328 | + FROM (((cards c_1 |
| 329 | + JOIN printings p_1 ON (((c_1.id)::text = p_1.card_id))) |
| 330 | + JOIN card_sets cs ON ((p_1.card_set_id = (cs.id)::text))) |
| 331 | + JOIN card_cycles cc ON (((cc.id)::text = cs.card_cycle_id))) |
| 332 | + GROUP BY c_1.id |
| 333 | + ), card_sets_summary AS ( |
| 334 | + SELECT c_1.id, |
| 335 | + array_agg(cs.id ORDER BY cs.id) AS card_set_ids, |
| 336 | + array_agg(lower(cs.name) ORDER BY (lower(cs.name))) AS card_set_names |
| 337 | + FROM ((cards c_1 |
| 338 | + JOIN printings p_1 ON (((c_1.id)::text = p_1.card_id))) |
| 339 | + JOIN card_sets cs ON ((p_1.card_set_id = (cs.id)::text))) |
| 340 | + GROUP BY c_1.id |
| 341 | + ), card_subtype_ids AS ( |
| 342 | + SELECT cards_card_subtypes.card_id, |
| 343 | + array_agg(cards_card_subtypes.card_subtype_id ORDER BY 1::integer) AS card_subtype_ids |
| 344 | + FROM cards_card_subtypes |
| 345 | + GROUP BY cards_card_subtypes.card_id |
| 346 | + ), card_subtype_names AS ( |
| 347 | + SELECT ccs_1.card_id, |
| 348 | + array_agg(lower(cs.name) ORDER BY (lower(cs.name))) AS lower_card_subtype_names, |
| 349 | + array_agg(cs.name ORDER BY cs.name) AS card_subtype_names |
| 350 | + FROM (cards_card_subtypes ccs_1 |
| 351 | + JOIN card_subtypes cs ON ((ccs_1.card_subtype_id = (cs.id)::text))) |
| 352 | + GROUP BY ccs_1.card_id |
| 353 | + ), card_printing_ids AS ( |
| 354 | + SELECT printings.card_id, |
| 355 | + array_agg(printings.id ORDER BY printings.date_release DESC) AS printing_ids |
| 356 | + FROM printings |
| 357 | + GROUP BY printings.card_id |
| 358 | + ), card_restriction_ids AS ( |
| 359 | + SELECT unified_restrictions.card_id, |
| 360 | + array_agg(unified_restrictions.restriction_id ORDER BY unified_restrictions.restriction_id) AS restriction_ids |
| 361 | + FROM unified_restrictions |
| 362 | + WHERE unified_restrictions.in_restriction |
| 363 | + GROUP BY unified_restrictions.card_id |
| 364 | + ), restrictions_banned_summary AS ( |
| 365 | + SELECT restrictions_cards_banned.card_id, |
| 366 | + array_agg(restrictions_cards_banned.restriction_id ORDER BY restrictions_cards_banned.restriction_id) AS restrictions_banned |
| 367 | + FROM restrictions_cards_banned |
| 368 | + GROUP BY restrictions_cards_banned.card_id |
| 369 | + ), restrictions_global_penalty_summary AS ( |
| 370 | + SELECT restrictions_cards_global_penalty.card_id, |
| 371 | + array_agg(restrictions_cards_global_penalty.restriction_id ORDER BY restrictions_cards_global_penalty.restriction_id) AS restrictions_global_penalty |
| 372 | + FROM restrictions_cards_global_penalty |
| 373 | + GROUP BY restrictions_cards_global_penalty.card_id |
| 374 | + ), restrictions_points_summary AS ( |
| 375 | + SELECT restrictions_cards_points.card_id, |
| 376 | + array_agg(concat(restrictions_cards_points.restriction_id, '=', (restrictions_cards_points.value)::text) ORDER BY (concat(restrictions_cards_points.restriction_id, '=', (restrictions_cards_points.value)::text))) AS restrictions_points |
| 377 | + FROM restrictions_cards_points |
| 378 | + GROUP BY restrictions_cards_points.card_id |
| 379 | + ), restrictions_restricted_summary AS ( |
| 380 | + SELECT restrictions_cards_restricted.card_id, |
| 381 | + array_agg(restrictions_cards_restricted.restriction_id ORDER BY restrictions_cards_restricted.restriction_id) AS restrictions_restricted |
| 382 | + FROM restrictions_cards_restricted |
| 383 | + GROUP BY restrictions_cards_restricted.card_id |
| 384 | + ), restrictions_universal_faction_cost_summary AS ( |
| 385 | + SELECT restrictions_cards_universal_faction_cost.card_id, |
| 386 | + array_agg(concat(restrictions_cards_universal_faction_cost.restriction_id, '=', (restrictions_cards_universal_faction_cost.value)::text) ORDER BY (concat(restrictions_cards_universal_faction_cost.restriction_id, '=', (restrictions_cards_universal_faction_cost.value)::text))) AS restrictions_universal_faction_cost |
| 387 | + FROM restrictions_cards_universal_faction_cost |
| 388 | + GROUP BY restrictions_cards_universal_faction_cost.card_id |
| 389 | + ), format_ids AS ( |
| 390 | + SELECT cpc_1.card_id, |
| 391 | + array_agg(DISTINCT s_1.format_id ORDER BY s_1.format_id) AS format_ids |
| 392 | + FROM (card_pools_cards cpc_1 |
| 393 | + JOIN snapshots s_1 ON ((cpc_1.card_pool_id = s_1.card_pool_id))) |
| 394 | + GROUP BY cpc_1.card_id |
| 395 | + ), card_pool_ids AS ( |
| 396 | + SELECT cpc_1.card_id, |
| 397 | + array_agg(DISTINCT s_1.card_pool_id ORDER BY s_1.card_pool_id) AS card_pool_ids |
| 398 | + FROM (card_pools_cards cpc_1 |
| 399 | + JOIN snapshots s_1 ON ((cpc_1.card_pool_id = s_1.card_pool_id))) |
| 400 | + GROUP BY cpc_1.card_id |
| 401 | + ), snapshot_ids AS ( |
| 402 | + SELECT cpc_1.card_id, |
| 403 | + array_agg(DISTINCT s_1.id ORDER BY s_1.id) AS snapshot_ids |
| 404 | + FROM (card_pools_cards cpc_1 |
| 405 | + JOIN snapshots s_1 ON ((cpc_1.card_pool_id = s_1.card_pool_id))) |
| 406 | + GROUP BY cpc_1.card_id |
| 407 | + ) |
| 408 | + SELECT c.id, |
| 409 | + c.title, |
| 410 | + c.stripped_title, |
| 411 | + c.card_type_id, |
| 412 | + c.side_id, |
| 413 | + c.faction_id, |
| 414 | + c.advancement_requirement, |
| 415 | + c.agenda_points, |
| 416 | + c.base_link, |
| 417 | + c.cost, |
| 418 | + c.deck_limit, |
| 419 | + c.influence_cost, |
| 420 | + c.influence_limit, |
| 421 | + c.memory_cost, |
| 422 | + c.minimum_deck_size, |
| 423 | + c.strength, |
| 424 | + c.stripped_text, |
| 425 | + c.text, |
| 426 | + c.trash_cost, |
| 427 | + c.is_unique, |
| 428 | + c.display_subtypes, |
| 429 | + c.created_at, |
| 430 | + c.updated_at, |
| 431 | + c.additional_cost, |
| 432 | + c.advanceable, |
| 433 | + c.gains_subroutines, |
| 434 | + c.interrupt, |
| 435 | + c.link_provided, |
| 436 | + c.mu_provided, |
| 437 | + c.num_printed_subroutines, |
| 438 | + c.on_encounter_effect, |
| 439 | + c.performs_trace, |
| 440 | + c.recurring_credits_provided, |
| 441 | + c.rez_effect, |
| 442 | + c.trash_ability, |
| 443 | + COALESCE(csi.card_subtype_ids, ARRAY[]::text[]) AS card_subtype_ids, |
| 444 | + COALESCE(csn.lower_card_subtype_names, ARRAY[]::text[]) AS lower_card_subtype_names, |
| 445 | + COALESCE(csn.card_subtype_names, ARRAY[]::text[]) AS card_subtype_names, |
| 446 | + p.printing_ids, |
| 447 | + array_length(p.printing_ids, 1) AS num_printings, |
| 448 | + ccs.card_cycle_ids, |
| 449 | + ccs.card_cycle_names, |
| 450 | + css.card_set_ids, |
| 451 | + css.card_set_names, |
| 452 | + COALESCE(r.restriction_ids, (ARRAY[]::text[])::character varying[]) AS restriction_ids, |
| 453 | + (r.restriction_ids IS NOT NULL) AS in_restriction, |
| 454 | + COALESCE(r_b.restrictions_banned, ARRAY[]::text[]) AS restrictions_banned, |
| 455 | + COALESCE(r_g_p.restrictions_global_penalty, ARRAY[]::text[]) AS restrictions_global_penalty, |
| 456 | + COALESCE(r_p.restrictions_points, ARRAY[]::text[]) AS restrictions_points, |
| 457 | + COALESCE(r_r.restrictions_restricted, ARRAY[]::text[]) AS restrictions_restricted, |
| 458 | + COALESCE(r_u_f_c.restrictions_universal_faction_cost, ARRAY[]::text[]) AS restrictions_universal_faction_cost, |
| 459 | + COALESCE(f.format_ids, ARRAY[]::text[]) AS format_ids, |
| 460 | + COALESCE(cpc.card_pool_ids, ARRAY[]::text[]) AS card_pool_ids, |
| 461 | + COALESCE(s.snapshot_ids, (ARRAY[]::text[])::character varying[]) AS snapshot_ids |
| 462 | + FROM ((((((((((((((cards c |
| 463 | + JOIN card_printing_ids p ON (((c.id)::text = p.card_id))) |
| 464 | + JOIN card_cycles_summary ccs ON (((c.id)::text = (ccs.id)::text))) |
| 465 | + JOIN card_sets_summary css ON (((c.id)::text = (css.id)::text))) |
| 466 | + LEFT JOIN card_subtype_ids csi ON (((c.id)::text = csi.card_id))) |
| 467 | + LEFT JOIN card_subtype_names csn ON (((c.id)::text = csn.card_id))) |
| 468 | + LEFT JOIN card_restriction_ids r ON (((c.id)::text = (r.card_id)::text))) |
| 469 | + LEFT JOIN restrictions_banned_summary r_b ON (((c.id)::text = r_b.card_id))) |
| 470 | + LEFT JOIN restrictions_global_penalty_summary r_g_p ON (((c.id)::text = r_g_p.card_id))) |
| 471 | + LEFT JOIN restrictions_points_summary r_p ON (((c.id)::text = r_p.card_id))) |
| 472 | + LEFT JOIN restrictions_restricted_summary r_r ON (((c.id)::text = r_r.card_id))) |
| 473 | + LEFT JOIN restrictions_universal_faction_cost_summary r_u_f_c ON (((c.id)::text = r_u_f_c.card_id))) |
| 474 | + LEFT JOIN format_ids f ON (((c.id)::text = f.card_id))) |
| 475 | + LEFT JOIN card_pool_ids cpc ON (((c.id)::text = cpc.card_id))) |
| 476 | + LEFT JOIN snapshot_ids s ON (((c.id)::text = s.card_id))) |
| 477 | + GROUP BY c.id, c.title, c.stripped_title, c.card_type_id, c.side_id, c.faction_id, c.advancement_requirement, c.agenda_points, c.base_link, c.cost, c.deck_limit, c.influence_cost, c.influence_limit, c.memory_cost, c.minimum_deck_size, c.strength, c.stripped_text, c.text, c.trash_cost, c.is_unique, c.display_subtypes, c.created_at, c.updated_at, c.additional_cost, c.advanceable, c.gains_subroutines, c.interrupt, c.link_provided, c.mu_provided, c.num_printed_subroutines, c.on_encounter_effect, c.performs_trace, c.recurring_credits_provided, c.rez_effect, c.trash_ability, csi.card_subtype_ids, csn.lower_card_subtype_names, csn.card_subtype_names, p.printing_ids, ccs.card_cycle_ids, ccs.card_cycle_names, css.card_set_ids, css.card_set_names, r.restriction_ids, r_b.restrictions_banned, r_g_p.restrictions_global_penalty, r_p.restrictions_points, r_r.restrictions_restricted, r_u_f_c.restrictions_universal_faction_cost, f.format_ids, cpc.card_pool_ids, s.snapshot_ids; |
| 478 | + SQL |
323 | 479 | end
|
0 commit comments