DROP TABLE IF EXISTS character_collection_items;
CREATE TABLE character_collection_items (
	id                  INTEGER PRIMARY KEY,
	char_id             INTEGER NOT NULL,
	collection_id       INTEGER NOT NULL,
	collection_item_id  INTEGER NOT NULL,
	UNIQUE(char_id, collection_id, collection_item_id),
	FOREIGN KEY (char_id) REFERENCES characters(id) ON DELETE CASCADE ON UPDATE CASCADE,
	FOREIGN KEY (collection_id) REFERENCES collections(id) ON DELETE CASCADE ON UPDATE CASCADE,
	FOREIGN KEY (collection_item_id) REFERENCES items(id) ON DELETE CASCADE ON UPDATE CASCADE
);
CREATE INDEX idx_character_collection_items_collection_id ON character_collection_items(collection_id);
CREATE INDEX idx_character_collection_items_collection_item_id ON character_collection_items(collection_item_id);

INSERT INTO character_collection_items VALUES
(18690,3723,545,6612),
(18689,3723,551,3280),
(18725,3724,545,7024),
(18724,3724,545,13156),
(18692,3724,551,5470),
(18691,3724,551,9948),
(18696,3726,545,6612),
(18695,3726,545,6645),
(18700,3726,545,7024),
(18704,3726,545,8061),
(18709,3726,545,13156),
(18705,3726,551,9948),
(18719,3727,545,6612),
(18716,3727,545,6645),
(18718,3727,545,8061),
(18717,3727,545,13156),
(18723,3738,545,6645),
(18820,3742,412,4959),
(18795,3742,416,4960),
(18817,3742,418,12649),
(18818,3742,421,12652),
(18819,3742,424,12655),
(18762,3742,544,4957),
(18797,3742,544,4958),
(18769,3742,544,4959),
(18781,3742,544,4960),
(18730,3742,545,6612),
(18731,3742,545,6645),
(18753,3742,545,7024),
(18750,3742,545,8061),
(18746,3742,545,13156),
(18800,3742,550,12619),
(18782,3742,550,12645),
(18763,3742,550,12646),
(18771,3742,550,12649),
(18776,3742,550,12650),
(18792,3742,550,12652),
(18814,3742,550,12655),
(18766,3742,550,12658),
(18761,3742,550,12672),
(18732,3742,551,3280),
(18741,3742,551,5038),
(18727,3742,551,5470),
(18738,3742,551,9948),
(18729,3742,551,14749),
(18848,3768,545,8061),
(18849,3768,551,3280),
(18821,3768,551,9948),
(18822,3770,551,3280),
(18869,3771,545,6612),
(18833,3771,545,6645),
(18836,3771,545,7024),
(18824,3771,545,8061),
(18841,3771,545,13156),
(19060,3771,550,12672),
(18879,3771,551,3280),
(18825,3771,551,5038),
(18884,3771,551,5470),
(18827,3771,551,9948),
(18867,3771,551,14749),
(18843,3772,545,6612),
(18838,3772,545,6645),
(18847,3772,545,7024),
(18860,3772,545,13156),
(18853,3772,551,3280),
(18828,3772,551,5038),
(18830,3772,551,5470),
(18823,3772,551,9948),
(18864,3772,551,14749),
(18851,3773,545,6612),
(18852,3773,551,3280),
(19487,3774,405,4956),
(19515,3774,406,5531),
(18969,3774,408,4957),
(18964,3774,411,5564),
(18958,3774,414,5565),
(19462,3774,416,4960),
(19002,3774,416,12032),
(18962,3774,417,12648),
(19007,3774,418,5571),
(19508,3774,419,5572),
(18963,3774,419,12650),
(18967,3774,422,5575),
(19497,3774,422,12653),
(19498,3774,423,12654),
(18965,3774,424,12655),
(18961,3774,425,12656),
(18966,3774,429,5588),
(18982,3774,431,12664),
(19540,3774,438,5628),
(18960,3774,438,12672),
(18992,3774,518,5531),
(19433,3774,518,5564),
(18976,3774,518,5565),
(18984,3774,518,5567),
(19520,3774,518,5570),
(18988,3774,518,5571),
(19012,3774,518,5572),
(19438,3774,518,5575),
(19483,3774,518,5583),
(18978,3774,518,5588),
(19020,3774,518,5591),
(19461,3774,518,5628),
(18970,3774,530,12030),
(19022,3774,530,12031),
(18998,3774,530,12032),
(19510,3774,544,4955),
(18971,3774,544,4956),
(18968,3774,544,4957),
(18981,3774,544,4960),
(18899,3774,545,6612),
(18894,3774,545,6645),
(18893,3774,545,7024),
(18905,3774,545,8061),
(18909,3774,545,13156),
(19475,3774,548,10422),
(19555,3774,548,10424),
(19528,3774,550,12619),
(19544,3774,550,12643),
(19499,3774,550,12645),
(19003,3774,550,12648),
(19489,3774,550,12653),
(19465,3774,550,12654),
(18973,3774,550,12655),
(19443,3774,550,12656),
(19000,3774,550,12662),
(19450,3774,550,12663),
(18975,3774,550,12664),
(18949,3774,551,3280),
(18896,3774,551,5038),
(18911,3774,551,5470),
(18898,3774,551,9948),
(19471,3774,552,13262),
(19472,3774,553,13458),
(18959,3774,553,13471),
(18991,3774,553,13495),
(18923,3777,235,7875),
(18924,3777,477,6306),
(18917,3777,477,7397),
(18936,3777,483,3853),
(18944,3777,483,5584),
(18918,3777,483,6489),
(18942,3777,483,12659),
(18920,3777,506,10106),
(18947,3777,514,7862),
(18929,3777,514,12018),
(18938,3777,518,5571),
(18915,3777,518,5574),
(18916,3777,519,5055),
(18932,3777,523,7085),
(18921,3777,523,7950),
(18919,3777,523,13248),
(18928,3777,523,13484),
(18914,3777,546,7840),
(18931,3777,546,10462),
(19024,3786,551,3280),
(19036,3786,551,5038),
(19031,3786,551,5470),
(19029,3786,551,9948),
(19026,3786,551,14749),
(19213,3788,500,10968),
(19051,3788,545,6612),
(19046,3788,545,6645),
(19049,3788,545,7024),
(19059,3788,545,8061),
(19045,3788,545,13156),
(19102,3788,550,12648),
(19090,3788,551,3280),
(19099,3788,551,5038),
(19094,3788,551,5470),
(19044,3788,551,9948),
(19083,3788,551,14749),
(19074,3792,545,6612),
(19067,3792,545,6645),
(19068,3792,545,13156),
(19063,3792,551,3280),
(19064,3792,551,5038),
(19070,3792,551,5470),
(19062,3792,551,9948),
(19061,3792,551,14749),
(19140,3806,406,12619),
(19333,3806,408,12029),
(19278,3806,409,4958),
(19188,3806,411,5564),
(19168,3806,414,5565),
(19145,3806,414,12645),
(19147,3806,415,5567),
(19146,3806,415,12646),
(19171,3806,416,12032),
(19170,3806,417,5570),
(19177,3806,417,12648),
(19141,3806,418,5571),
(19309,3806,418,12649),
(19138,3806,421,12652),
(19252,3806,422,5575),
(19178,3806,423,5579),
(19338,3806,424,12655),
(19396,3806,425,5581),
(19263,3806,425,12656),
(19339,3806,427,12658),
(19175,3806,429,5588),
(19270,3806,429,12662),
(19157,3806,437,12669),
(19191,3806,518,5564),
(19189,3806,518,5565),
(19167,3806,518,5571),
(19313,3806,518,5572),
(19285,3806,518,5574),
(19231,3806,518,5575),
(19304,3806,518,5581),
(19358,3806,518,5583),
(19243,3806,518,5588),
(19276,3806,518,5589),
(19204,3806,518,5628),
(19362,3806,526,4543),
(19152,3806,530,12027),
(19265,3806,530,12029),
(19155,3806,530,12030),
(19196,3806,530,12031),
(19151,3806,530,12032),
(19253,3806,544,4955),
(19413,3806,544,4956),
(19179,3806,544,4958),
(19281,3806,544,4959),
(19115,3806,545,6612),
(19104,3806,545,6645),
(19103,3806,545,7024),
(19127,3806,545,8061),
(19111,3806,545,13156),
(19139,3806,548,10404),
(19183,3806,548,10422),
(19322,3806,548,10424),
(19255,3806,550,12619),
(19324,3806,550,12643),
(19158,3806,550,12646),
(19246,3806,550,12649),
(19143,3806,550,12652),
(19235,3806,550,12653),
(19295,3806,550,12655),
(19166,3806,550,12656),
(19187,3806,550,12658),
(19349,3806,550,12662),
(19381,3806,550,12663),
(19394,3806,550,12664),
(19209,3806,550,12669),
(19107,3806,551,3280),
(19120,3806,551,5038),
(19134,3806,551,5470),
(19106,3806,551,9948),
(19113,3806,551,14749),
(19149,3806,552,13221),
(19173,3806,552,13234),
(19144,3806,552,13260),
(19370,3806,552,13262),
(19334,3806,553,13458),
(19160,3806,553,13471),
(19199,3806,553,13493),
(19142,3806,553,13495),
(19677,3808,409,4958),
(19660,3808,418,12649),
(19674,3808,421,12652),
(19661,3808,422,12653),
(19424,3808,424,12655),
(19430,3808,500,10968),
(19676,3808,500,10971),
(19684,3808,500,10973),
(19678,3808,518,5575),
(19701,3808,518,5580),
(19681,3808,530,12028),
(19688,3808,530,12030),
(19685,3808,532,3900),
(19431,3808,532,3901),
(19704,3808,532,3902),
(19429,3808,535,5051),
(19679,3808,537,10427),
(19705,3808,538,13227),
(19609,3808,544,4955),
(19416,3808,544,4958),
(19603,3808,544,4959),
(19673,3808,544,4960),
(19210,3808,545,6612),
(19163,3808,545,6645),
(19181,3808,545,7024),
(19217,3808,545,8061),
(19221,3808,545,13156),
(19680,3808,549,11381),
(19662,3808,550,12619),
(19425,3808,550,12645),
(19420,3808,550,12649),
(19620,3808,550,12650),
(19606,3808,550,12652),
(19615,3808,550,12653),
(19418,3808,550,12655),
(19417,3808,550,12658),
(19697,3808,550,12664),
(19698,3808,550,12669),
(19699,3808,550,12672),
(19407,3808,551,3280),
(19400,3808,551,5038),
(19403,3808,551,5470),
(19162,3808,551,9948),
(19398,3808,551,14749),
(19561,3810,545,6612),
(19558,3810,545,6645),
(19542,3810,545,7024),
(19576,3810,545,8061),
(19557,3810,545,13156),
(19565,3810,551,3280),
(19538,3810,551,5038),
(19598,3810,551,5470),
(19514,3810,551,9948),
(19570,3810,551,14749),
(19646,3817,545,6612),
(19651,3817,545,6645),
(19635,3817,545,7024),
(19637,3817,545,8061),
(19639,3817,545,13156),
(19641,3817,551,3280),
(19628,3817,551,5038),
(19631,3817,551,5470),
(19625,3817,551,9948),
(19626,3817,551,14749),
(19706,3825,551,5038),
(19709,3825,551,5470),
(19708,3825,551,9948),
(19712,3826,545,8061),
(19920,3827,403,4955),
(19999,3827,403,10968),
(19845,3827,403,12027),
(19801,3827,405,4956),
(20028,3827,405,10969),
(19965,3827,405,12028),
(20017,3827,406,5531),
(19795,3827,406,12619),
(19798,3827,408,4957),
(20011,3827,408,10970),
(19864,3827,408,12029),
(19790,3827,409,4958),
(19828,3827,409,10971),
(20091,3827,409,12030),
(19787,3827,412,4959),
(20040,3827,412,10972),
(19869,3827,412,12031),
(19939,3827,414,5565),
(19796,3827,414,12645),
(19846,3827,415,5567),
(19791,3827,415,12646),
(19789,3827,416,4960),
(19874,3827,416,10973),
(19867,3827,417,5570),
(19923,3827,417,12648),
(20002,3827,418,5571),
(19797,3827,418,12649),
(19843,3827,419,5572),
(19788,3827,419,12650),
(19871,3827,421,5574),
(19799,3827,421,12652),
(20030,3827,422,5575),
(19784,3827,422,12653),
(20025,3827,423,5579),
(19800,3827,423,12654),
(19829,3827,424,5580),
(19822,3827,424,12655),
(19866,3827,425,5581),
(19984,3827,425,12656),
(19841,3827,427,5583),
(19785,3827,427,12658),
(19877,3827,429,5588),
(19996,3827,429,12662),
(19870,3827,430,5589),
(19875,3827,431,12664),
(20037,3827,437,5603),
(19786,3827,438,12672),
(20134,3827,500,10971),
(20038,3827,500,10973),
(20092,3827,518,5565),
(20013,3827,518,5570),
(19956,3827,518,5574),
(20054,3827,518,5579),
(20005,3827,518,5580),
(20022,3827,518,5583),
(19941,3827,518,5589),
(20044,3827,530,12027),
(20032,3827,530,12028),
(20042,3827,532,3900),
(19865,3827,532,3901),
(20087,3827,532,3903),
(20080,3827,532,3905),
(20144,3827,532,3906),
(20007,3827,535,4295),
(19954,3827,535,5051),
(19942,3827,535,11327),
(20033,3827,537,10407),
(19905,3827,537,10427),
(19958,3827,538,13227),
(19876,3827,538,13253),
(20138,3827,538,13261),
(20084,3827,538,13265),
(20035,3827,539,13464),
(20024,3827,539,13486),
(19934,3827,544,4955),
(19809,3827,544,4956),
(19804,3827,544,4957),
(19802,3827,544,4958),
(19970,3827,544,4959),
(20051,3827,544,4960),
(19719,3827,545,6612),
(19723,3827,545,6645),
(19717,3827,545,7024),
(19716,3827,545,8061),
(19729,3827,545,13156),
(20081,3827,549,11380),
(19831,3827,550,12619),
(19944,3827,550,12645),
(19816,3827,550,12646),
(19926,3827,550,12648),
(19850,3827,550,12649),
(19812,3827,550,12650),
(19977,3827,550,12652),
(19793,3827,550,12653),
(19807,3827,550,12654),
(19861,3827,550,12655),
(19903,3827,550,12658),
(19792,3827,550,12672),
(19736,3827,551,3280),
(19714,3827,551,5038),
(19744,3827,551,5470),
(19713,3827,551,9948),
(19741,3827,551,14749),
(19774,3830,545,6612),
(19765,3830,545,6645),
(19768,3830,545,7024),
(19755,3830,545,8061),
(19772,3830,545,13156),
(19756,3830,551,3280),
(19750,3830,551,5038),
(19748,3830,551,5470),
(19754,3830,551,9948),
(19763,3830,551,14749),
(19751,3831,551,5470),
(19823,3833,545,6612),
(19911,3833,545,6645),
(19821,3833,545,7024),
(19909,3833,545,8061),
(19908,3833,545,13156),
(19837,3833,551,3280),
(19803,3833,551,5038),
(19838,3833,551,5470),
(19826,3833,551,9948),
(19918,3833,551,14749),
(19881,3841,545,6612),
(19892,3841,545,6645),
(19883,3841,545,7024),
(19890,3841,545,8061),
(19886,3841,545,13156),
(19992,3841,551,3280),
(19879,3841,551,5038),
(19878,3841,551,9948),
(19960,3842,539,13486),
(19938,3846,551,5038),
(19961,3848,551,5470),
(19963,3848,551,14749),
(19997,3862,551,9948),
(20001,3874,551,5038),
(20150,3878,403,4955),
(20151,3878,406,12619),
(20152,3878,409,4958),
(20153,3878,423,12654),
(20154,3878,544,4955),
(20103,3878,545,6612),
(20099,3878,545,7024),
(20123,3878,545,8061),
(20102,3878,545,13156),
(20130,3878,551,5038),
(20124,3878,551,9948),
(20133,3883,544,4960),
(20100,3883,545,6612),
(20109,3883,545,6645),
(20105,3883,545,7024),
(20119,3883,545,8061),
(20114,3883,545,13156),
(20132,3883,550,12652),
(20061,3883,551,3280),
(20065,3883,551,5038),
(20069,3883,551,5470),
(20058,3883,551,9948),
(20059,3883,551,14749),
(20148,3886,545,6612),
(20147,3886,545,13156),
(20145,3886,551,9948);
