kithe 2.0.0.pre.alpha2 → 2.0.0.pre.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/app/jobs/kithe/create_derivatives_job.rb +2 -2
  3. data/app/models/kithe/asset.rb +82 -154
  4. data/app/models/kithe/asset/derivative_creator.rb +32 -62
  5. data/app/models/kithe/asset/derivative_definition.rb +12 -13
  6. data/app/models/kithe/asset/set_shrine_uploader.rb +64 -0
  7. data/app/models/kithe/collection.rb +0 -6
  8. data/app/models/kithe/model.rb +0 -21
  9. data/app/models/kithe/work.rb +0 -5
  10. data/app/uploaders/kithe/asset_uploader.rb +15 -78
  11. data/lib/kithe/version.rb +4 -1
  12. data/lib/shrine/plugins/kithe_checksum_signatures.rb +41 -0
  13. data/lib/shrine/plugins/kithe_controllable_backgrounding.rb +53 -0
  14. data/lib/shrine/plugins/kithe_derivative_definitions.rb +101 -0
  15. data/lib/shrine/plugins/kithe_derivatives.rb +54 -0
  16. data/lib/shrine/plugins/kithe_determine_mime_type.rb +39 -0
  17. data/lib/shrine/plugins/kithe_persisted_derivatives.rb +161 -0
  18. data/lib/shrine/plugins/kithe_promotion_callbacks.rb +4 -0
  19. data/lib/shrine/plugins/kithe_promotion_directives.rb +33 -3
  20. data/lib/shrine/plugins/kithe_storage_location.rb +53 -4
  21. data/lib/tasks/kithe_tasks.rake +22 -15
  22. data/spec/dummy/log/development.log +867 -0
  23. data/spec/dummy/log/test.log +26005 -0
  24. data/spec/models/kithe/asset/asset_derivatives_spec.rb +137 -0
  25. data/spec/models/kithe/asset/asset_promotion_hooks_spec.rb +26 -5
  26. data/spec/models/kithe/asset/set_shrine_uploader_spec.rb +39 -0
  27. data/spec/models/kithe/asset_spec.rb +9 -59
  28. data/spec/models/kithe/model_spec.rb +0 -32
  29. data/spec/shrine/kithe_accept_remote_url_spec.rb +49 -0
  30. data/spec/shrine/kithe_checksum_signatures_spec.rb +63 -0
  31. data/spec/shrine/kithe_derivative_definitions_spec.rb +303 -0
  32. data/spec/shrine/kithe_persisted_derivatives_spec.rb +424 -0
  33. data/spec/shrine/kithe_storage_location_spec.rb +43 -15
  34. data/spec/spec_helper.rb +7 -6
  35. data/spec/test_support/images/3x3_pixel.jpg +0 -0
  36. data/spec/test_support/shrine_spec_support.rb +2 -1
  37. metadata +23 -23
  38. data/app/models/kithe/asset/derivative_updater.rb +0 -119
  39. data/app/models/kithe/derivative.rb +0 -15
  40. data/app/uploaders/kithe/derivative_uploader.rb +0 -48
  41. data/spec/models/kithe/asset/asset_create_derivatives_spec.rb +0 -320
  42. data/spec/models/kithe/derivative_spec.rb +0 -168
@@ -108670,3 +108670,870 @@ Preloading Single-Table Inheritance type Kithe::Asset for Kithe::Model
108670
108670
  Kithe::Asset Update (3.3ms) UPDATE "kithe_models" SET "updated_at" = $1, "file_data" = $2 WHERE "kithe_models"."id" = $3 [["updated_at", "2020-05-12 19:16:26.883198"], ["file_data", "{\"id\":\"asset/e7e4d65b-b65f-43f4-a31a-9e6721a2116e/db52cb74ee881897ced47baa2bcd65c7.jpg\",\"storage\":\"store\",\"metadata\":{\"md5\":\"13a91cf5b51e9c7f0c1e4c1971d68348\",\"sha1\":\"8de724f54e231a7c41c618cf1918a1bb4070e6c9\",\"size\":209630,\"width\":717,\"height\":478,\"sha512\":\"3a7df0d5dfeb8219f379c873d33518f3f01f85e8706546a633029226a81294a0aff0858b29dffecd7f0a5816be766dd8182c58f18ae364c0798308cd17e810f6\",\"filename\":null,\"mime_type\":\"image/jpeg\",\"derivatives_created\":true},\"derivatives\":{\"animage\":{\"id\":\"e7e4d65b-b65f-43f4-a31a-9e6721a2116e/animage/a010cb42443f085e9f7a800d9051721e.jpeg\",\"storage\":\"kithe_derivatives\",\"metadata\":{\"filename\":\"kithe_models_friendlier_id_gen(1,10000000000)_animage.jpeg\",\"size\":312648,\"mime_type\":\"image/jpeg\",\"width\":2045,\"height\":1376,\"md5\":\"e55e2c43660e252ae58ab9e65912a509\",\"sha1\":\"ee867b5ea12915115a6b9706b0d281b4bf067968\",\"sha512\":\"28072fde08738656e73a2f8ee2ebc35c8df32cb86e03656285c5ce787b28df339bfe30612ae191ae818d5d1eca0cf85ec3f2643f752cb12e28d5a3b5215c3836\"}}}}"], ["id", "e7e4d65b-b65f-43f4-a31a-9e6721a2116e"]]
108671
108671
   (0.7ms) COMMIT
108672
108672
  Kithe::Asset Load (0.5ms) SELECT "kithe_models"."id", "kithe_models"."title", "kithe_models"."type", "kithe_models"."position", "kithe_models"."json_attributes", "kithe_models"."created_at", "kithe_models"."updated_at", "kithe_models"."parent_id", "kithe_models"."friendlier_id", "kithe_models"."file_data", "kithe_models"."kithe_model_type" FROM "kithe_models" WHERE "kithe_models"."type" = $1 AND "kithe_models"."id" = $2 LIMIT $3 [["type", "Kithe::Asset"], ["id", "e7e4d65b-b65f-43f4-a31a-9e6721a2116e"], ["LIMIT", 1]]
108673
+  (2.6ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
108674
+  (0.9ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
108675
+  (0.8ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
108676
+  (23.7ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
108677
+  (0.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
108678
+  (0.3ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
108679
+  (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
108680
+  (0.2ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
108681
+  (233.0ms) DROP DATABASE IF EXISTS "kithe_development"
108682
+  (316.2ms) DROP DATABASE IF EXISTS "kithe_test"
108683
+  (480.0ms) CREATE DATABASE "kithe_development" ENCODING = 'unicode'
108684
+  (446.4ms) CREATE DATABASE "kithe_test" ENCODING = 'unicode'
108685
+  (6.9ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)
108686
+  (22.7ms) CREATE TABLE "ar_internal_metadata" ("key" character varying NOT NULL PRIMARY KEY, "value" character varying, "created_at" timestamp(6) NOT NULL, "updated_at" timestamp(6) NOT NULL)
108687
+  (0.4ms) SELECT pg_try_advisory_lock(1601470156486188030)
108688
+  (0.9ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
108689
+ Migrating to EnablePgcryptoExtension (20181015143259)
108690
+  (0.2ms) BEGIN
108691
+ SQL (33.2ms) CREATE EXTENSION IF NOT EXISTS "pgcrypto"
108692
+ primary::SchemaMigration Create (0.5ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20181015143259"]]
108693
+  (6.5ms) COMMIT
108694
+ Migrating to CreateKitheModels (20181015143413)
108695
+  (0.7ms) BEGIN
108696
+  (28.7ms) CREATE TABLE "kithe_models" ("id" uuid DEFAULT gen_random_uuid() NOT NULL PRIMARY KEY, "title" character varying NOT NULL, "type" character varying NOT NULL, "position" integer, "json_attributes" jsonb, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
108697
+  (1.2ms) ALTER TABLE "kithe_models" ADD "parent_id" uuid
108698
+  (1.3ms) CREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")
108699
+  (2.9ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
108700
+ FOREIGN KEY ("parent_id")
108701
+ REFERENCES "kithe_models" ("id")
108702
+ 
108703
+ primary::SchemaMigration Create (0.5ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20181015143413"]]
108704
+  (0.8ms) COMMIT
108705
+ Migrating to KitheModelsFriendlierId (20181015143737)
108706
+  (0.3ms) BEGIN
108707
+  (21.5ms) CREATE OR REPLACE FUNCTION kithe_models_friendlier_id_gen(min_value bigint, max_value bigint) RETURNS text AS $$
108708
+ DECLARE
108709
+ new_id_int bigint;
108710
+ new_id_str character varying := '';
108711
+ done bool;
108712
+ tries integer;
108713
+ alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
108714
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
108715
+ 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
108716
+ alphabet_length integer := array_length(alphabet, 1);
108717
+
108718
+ BEGIN
108719
+ done := false;
108720
+ tries := 0;
108721
+ WHILE (NOT done) LOOP
108722
+ tries := tries + 1;
108723
+ IF (tries > 3) THEN
108724
+ RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
108725
+ END IF;
108726
+
108727
+ new_id_int := trunc(random() * (max_value - min_value) + min_value);
108728
+
108729
+ -- convert bigint to a Base-36 alphanumeric string
108730
+ -- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
108731
+ -- https://gist.github.com/btbytes/7159902
108732
+ WHILE new_id_int != 0 LOOP
108733
+ new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
108734
+ new_id_int := new_id_int / alphabet_length;
108735
+ END LOOP;
108736
+
108737
+ done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
108738
+ END LOOP;
108739
+ RETURN new_id_str;
108740
+ END;
108741
+ $$ LANGUAGE plpgsql;
108742
+ 
108743
+  (28.2ms) ALTER TABLE "kithe_models" ADD "friendlier_id" character varying DEFAULT kithe_models_friendlier_id_gen(2821109907456, 101559956668415) NOT NULL
108744
+  (1.0ms) CREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")
108745
+ primary::SchemaMigration Create (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20181015143737"]]
108746
+  (1.2ms) COMMIT
108747
+ Migrating to AddFileDataToModel (20181031190647)
108748
+  (0.3ms) BEGIN
108749
+  (1.0ms) ALTER TABLE "kithe_models" ADD "file_data" jsonb
108750
+ primary::SchemaMigration Create (0.4ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20181031190647"]]
108751
+  (13.7ms) COMMIT
108752
+ Migrating to CreateKitheDerivatives (20181128185658)
108753
+  (0.3ms) BEGIN
108754
+  (17.8ms) CREATE TABLE "kithe_derivatives" ("id" bigserial primary key, "key" character varying NOT NULL, "file_data" jsonb, "asset_id" uuid NOT NULL, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL, CONSTRAINT "fk_rails_3dac8b4201"
108755
+ FOREIGN KEY ("asset_id")
108756
+ REFERENCES "kithe_models" ("id")
108757
+ )
108758
+  (6.2ms) CREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")
108759
+  (1.2ms) CREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")
108760
+ primary::SchemaMigration Create (0.4ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20181128185658"]]
108761
+  (0.4ms) COMMIT
108762
+ Migrating to AddRepresentativeRelations (20190103144947)
108763
+  (12.1ms) BEGIN
108764
+  (0.9ms) ALTER TABLE "kithe_models" ADD "representative_id" uuid
108765
+  (6.7ms) CREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")
108766
+  (1.6ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
108767
+ FOREIGN KEY ("representative_id")
108768
+ REFERENCES "kithe_models" ("id")
108769
+ 
108770
+  (0.5ms) ALTER TABLE "kithe_models" ADD "leaf_representative_id" uuid
108771
+  (1.0ms) CREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")
108772
+  (1.4ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
108773
+ FOREIGN KEY ("leaf_representative_id")
108774
+ REFERENCES "kithe_models" ("id")
108775
+ 
108776
+ primary::SchemaMigration Create (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20190103144947"]]
108777
+  (0.4ms) COMMIT
108778
+ Migrating to ContainsAssociation (20190109192252)
108779
+  (0.3ms) BEGIN
108780
+  (2.7ms) CREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid, CONSTRAINT "fk_rails_490c1158f7"
108781
+ FOREIGN KEY ("containee_id")
108782
+ REFERENCES "kithe_models" ("id")
108783
+ , CONSTRAINT "fk_rails_091010187b"
108784
+ FOREIGN KEY ("container_id")
108785
+ REFERENCES "kithe_models" ("id")
108786
+ )
108787
+  (7.4ms) CREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")
108788
+  (5.9ms) CREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")
108789
+ primary::SchemaMigration Create (0.4ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20190109192252"]]
108790
+  (0.4ms) COMMIT
108791
+ Migrating to KitheModelType (20190404144551)
108792
+  (0.3ms) BEGIN
108793
+  (0.7ms) ALTER TABLE "kithe_models" ADD "kithe_model_type" integer
108794
+  (0.4ms) SELECT "kithe_models"."id" FROM "kithe_models" ORDER BY "kithe_models"."id" ASC LIMIT $1 [["LIMIT", 1000]]
108795
+  (13.1ms) ALTER TABLE "kithe_models" ALTER COLUMN "kithe_model_type" TYPE integer, ALTER COLUMN "kithe_model_type" SET NOT NULL
108796
+ primary::SchemaMigration Create (0.4ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20190404144551"]]
108797
+  (5.9ms) COMMIT
108798
+ ActiveRecord::InternalMetadata Load (0.5ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
108799
+  (0.2ms) BEGIN
108800
+ ActiveRecord::InternalMetadata Create (0.7ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "environment"], ["value", "development"], ["created_at", "2020-05-20 19:49:53.472252"], ["updated_at", "2020-05-20 19:49:53.472252"]]
108801
+  (6.1ms) COMMIT
108802
+  (0.3ms) SELECT pg_advisory_unlock(1601470156486188030)
108803
+  (0.8ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
108804
+  (0.9ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
108805
+  (0.4ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
108806
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
108807
+  (0.2ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
108808
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
108809
+  (0.2ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
108810
+  (206.8ms) DROP DATABASE IF EXISTS "kithe_development"
108811
+  (203.9ms) DROP DATABASE IF EXISTS "kithe_test"
108812
+  (539.9ms) CREATE DATABASE "kithe_development" ENCODING = 'unicode'
108813
+  (419.2ms) CREATE DATABASE "kithe_test" ENCODING = 'unicode'
108814
+  (5.1ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)
108815
+  (4.4ms) CREATE TABLE "ar_internal_metadata" ("key" character varying NOT NULL PRIMARY KEY, "value" character varying, "created_at" timestamp(6) NOT NULL, "updated_at" timestamp(6) NOT NULL)
108816
+  (0.2ms) SELECT pg_try_advisory_lock(1601470156486188030)
108817
+  (0.6ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
108818
+ Migrating to EnablePgcryptoExtension (20181015143259)
108819
+  (0.2ms) BEGIN
108820
+ SQL (18.2ms) CREATE EXTENSION IF NOT EXISTS "pgcrypto"
108821
+ primary::SchemaMigration Create (0.5ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20181015143259"]]
108822
+  (6.1ms) COMMIT
108823
+ Migrating to CreateKitheModels (20181015143413)
108824
+  (0.3ms) BEGIN
108825
+  (18.8ms) CREATE TABLE "kithe_models" ("id" uuid DEFAULT gen_random_uuid() NOT NULL PRIMARY KEY, "title" character varying NOT NULL, "type" character varying NOT NULL, "position" integer, "json_attributes" jsonb, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
108826
+  (0.5ms) ALTER TABLE "kithe_models" ADD "parent_id" uuid
108827
+  (1.1ms) CREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")
108828
+  (3.1ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
108829
+ FOREIGN KEY ("parent_id")
108830
+ REFERENCES "kithe_models" ("id")
108831
+ 
108832
+ primary::SchemaMigration Create (0.5ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20181015143413"]]
108833
+  (0.5ms) COMMIT
108834
+ Migrating to KitheModelsFriendlierId (20181015143737)
108835
+  (0.3ms) BEGIN
108836
+  (2.3ms) CREATE OR REPLACE FUNCTION kithe_models_friendlier_id_gen(min_value bigint, max_value bigint) RETURNS text AS $$
108837
+ DECLARE
108838
+ new_id_int bigint;
108839
+ new_id_str character varying := '';
108840
+ done bool;
108841
+ tries integer;
108842
+ alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
108843
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
108844
+ 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
108845
+ alphabet_length integer := array_length(alphabet, 1);
108846
+
108847
+ BEGIN
108848
+ done := false;
108849
+ tries := 0;
108850
+ WHILE (NOT done) LOOP
108851
+ tries := tries + 1;
108852
+ IF (tries > 3) THEN
108853
+ RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
108854
+ END IF;
108855
+
108856
+ new_id_int := trunc(random() * (max_value - min_value) + min_value);
108857
+
108858
+ -- convert bigint to a Base-36 alphanumeric string
108859
+ -- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
108860
+ -- https://gist.github.com/btbytes/7159902
108861
+ WHILE new_id_int != 0 LOOP
108862
+ new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
108863
+ new_id_int := new_id_int / alphabet_length;
108864
+ END LOOP;
108865
+
108866
+ done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
108867
+ END LOOP;
108868
+ RETURN new_id_str;
108869
+ END;
108870
+ $$ LANGUAGE plpgsql;
108871
+ 
108872
+  (24.7ms) ALTER TABLE "kithe_models" ADD "friendlier_id" character varying DEFAULT kithe_models_friendlier_id_gen(2821109907456, 101559956668415) NOT NULL
108873
+  (1.2ms) CREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")
108874
+ primary::SchemaMigration Create (0.4ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20181015143737"]]
108875
+  (1.2ms) COMMIT
108876
+ Migrating to AddFileDataToModel (20181031190647)
108877
+  (0.4ms) BEGIN
108878
+  (0.4ms) ALTER TABLE "kithe_models" ADD "file_data" jsonb
108879
+ primary::SchemaMigration Create (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20181031190647"]]
108880
+  (11.3ms) COMMIT
108881
+ Migrating to CreateKitheDerivatives (20181128185658)
108882
+  (0.4ms) BEGIN
108883
+  (27.7ms) CREATE TABLE "kithe_derivatives" ("id" bigserial primary key, "key" character varying NOT NULL, "file_data" jsonb, "asset_id" uuid NOT NULL, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL, CONSTRAINT "fk_rails_3dac8b4201"
108884
+ FOREIGN KEY ("asset_id")
108885
+ REFERENCES "kithe_models" ("id")
108886
+ )
108887
+  (1.6ms) CREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")
108888
+  (1.6ms) CREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")
108889
+ primary::SchemaMigration Create (0.3ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20181128185658"]]
108890
+  (0.4ms) COMMIT
108891
+ Migrating to AddRepresentativeRelations (20190103144947)
108892
+  (43.7ms) BEGIN
108893
+  (0.4ms) ALTER TABLE "kithe_models" ADD "representative_id" uuid
108894
+  (2.8ms) CREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")
108895
+  (2.5ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
108896
+ FOREIGN KEY ("representative_id")
108897
+ REFERENCES "kithe_models" ("id")
108898
+ 
108899
+  (0.6ms) ALTER TABLE "kithe_models" ADD "leaf_representative_id" uuid
108900
+  (25.7ms) CREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")
108901
+  (12.6ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
108902
+ FOREIGN KEY ("leaf_representative_id")
108903
+ REFERENCES "kithe_models" ("id")
108904
+ 
108905
+ primary::SchemaMigration Create (5.1ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20190103144947"]]
108906
+  (2.0ms) COMMIT
108907
+ Migrating to ContainsAssociation (20190109192252)
108908
+  (0.9ms) BEGIN
108909
+  (23.6ms) CREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid, CONSTRAINT "fk_rails_490c1158f7"
108910
+ FOREIGN KEY ("containee_id")
108911
+ REFERENCES "kithe_models" ("id")
108912
+ , CONSTRAINT "fk_rails_091010187b"
108913
+ FOREIGN KEY ("container_id")
108914
+ REFERENCES "kithe_models" ("id")
108915
+ )
108916
+  (1.1ms) CREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")
108917
+  (1.0ms) CREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")
108918
+ primary::SchemaMigration Create (0.4ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20190109192252"]]
108919
+  (0.4ms) COMMIT
108920
+ Migrating to KitheModelType (20190404144551)
108921
+  (0.2ms) BEGIN
108922
+  (0.4ms) ALTER TABLE "kithe_models" ADD "kithe_model_type" integer
108923
+  (0.4ms) SELECT "kithe_models"."id" FROM "kithe_models" ORDER BY "kithe_models"."id" ASC LIMIT $1 [["LIMIT", 1000]]
108924
+  (0.6ms) ALTER TABLE "kithe_models" ALTER COLUMN "kithe_model_type" TYPE integer, ALTER COLUMN "kithe_model_type" SET NOT NULL
108925
+ primary::SchemaMigration Create (0.4ms) INSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version" [["version", "20190404144551"]]
108926
+  (6.4ms) COMMIT
108927
+ ActiveRecord::InternalMetadata Load (0.8ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
108928
+  (0.1ms) BEGIN
108929
+ ActiveRecord::InternalMetadata Create (0.6ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "environment"], ["value", "development"], ["created_at", "2020-05-20 19:50:47.121307"], ["updated_at", "2020-05-20 19:50:47.121307"]]
108930
+  (0.4ms) COMMIT
108931
+  (0.2ms) SELECT pg_advisory_unlock(1601470156486188030)
108932
+  (0.8ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
108933
+  (0.9ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
108934
+  (0.8ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
108935
+  (5.5ms)  SELECT
108936
+ pp.proname AS name,
108937
+ pg_get_functiondef(pp.oid) AS definition
108938
+ FROM pg_proc pp
108939
+ JOIN pg_namespace pn
108940
+ ON pn.oid = pp.pronamespace
108941
+ LEFT JOIN pg_depend pd
108942
+ ON pd.objid = pp.oid AND pd.deptype = 'e'
108943
+ WHERE pn.nspname = 'public' AND pd.objid IS NULL
108944
+ ORDER BY pp.oid;
108945
+ 
108946
+  (1.5ms)  SELECT
108947
+ pt.tgname AS name,
108948
+ pg_get_triggerdef(pt.oid) AS definition
108949
+ FROM pg_trigger pt
108950
+ JOIN pg_class pc
108951
+ ON (pc.oid = pt.tgrelid)
108952
+ JOIN pg_proc pp
108953
+ ON (pp.oid = pt.tgfoid)
108954
+ WHERE pt.tgname
108955
+ NOT ILIKE '%constraint%' AND pt.tgname NOT ILIKE 'pg%'
108956
+ ORDER BY pc.oid;
108957
+ 
108958
+  (0.2ms) SELECT pg_try_advisory_lock(1601470156486188030)
108959
+  (0.9ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
108960
+ ActiveRecord::InternalMetadata Load (0.5ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
108961
+  (0.4ms) SELECT pg_advisory_unlock(1601470156486188030)
108962
+  (0.9ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
108963
+  (4.1ms)  SELECT
108964
+ pp.proname AS name,
108965
+ pg_get_functiondef(pp.oid) AS definition
108966
+ FROM pg_proc pp
108967
+ JOIN pg_namespace pn
108968
+ ON pn.oid = pp.pronamespace
108969
+ LEFT JOIN pg_depend pd
108970
+ ON pd.objid = pp.oid AND pd.deptype = 'e'
108971
+ WHERE pn.nspname = 'public' AND pd.objid IS NULL
108972
+ ORDER BY pp.oid;
108973
+ 
108974
+  (1.3ms)  SELECT
108975
+ pt.tgname AS name,
108976
+ pg_get_triggerdef(pt.oid) AS definition
108977
+ FROM pg_trigger pt
108978
+ JOIN pg_class pc
108979
+ ON (pc.oid = pt.tgrelid)
108980
+ JOIN pg_proc pp
108981
+ ON (pp.oid = pt.tgfoid)
108982
+ WHERE pt.tgname
108983
+ NOT ILIKE '%constraint%' AND pt.tgname NOT ILIKE 'pg%'
108984
+ ORDER BY pc.oid;
108985
+ 
108986
+  (0.8ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
108987
+  (0.4ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
108988
+  (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
108989
+  (0.2ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
108990
+  (0.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
108991
+  (0.2ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
108992
+  (285.0ms) DROP DATABASE IF EXISTS "kithe_development"
108993
+  (211.1ms) DROP DATABASE IF EXISTS "kithe_test"
108994
+  (491.7ms) CREATE DATABASE "kithe_development" ENCODING = 'unicode'
108995
+  (411.0ms) CREATE DATABASE "kithe_test" ENCODING = 'unicode'
108996
+ SQL (36.2ms) CREATE EXTENSION IF NOT EXISTS "pgcrypto"
108997
+ SQL (0.2ms) CREATE EXTENSION IF NOT EXISTS "plpgsql"
108998
+  (10.5ms) CREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint)
108999
+ RETURNS text
109000
+ LANGUAGE plpgsql
109001
+ AS $function$
109002
+ DECLARE
109003
+ new_id_int bigint;
109004
+ new_id_str character varying := '';
109005
+ done bool;
109006
+ tries integer;
109007
+ alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
109008
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
109009
+ 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
109010
+ alphabet_length integer := array_length(alphabet, 1);
109011
+
109012
+ BEGIN
109013
+ done := false;
109014
+ tries := 0;
109015
+ WHILE (NOT done) LOOP
109016
+ tries := tries + 1;
109017
+ IF (tries > 3) THEN
109018
+ RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
109019
+ END IF;
109020
+
109021
+ new_id_int := trunc(random() * (max_value - min_value) + min_value);
109022
+
109023
+ -- convert bigint to a Base-36 alphanumeric string
109024
+ -- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
109025
+ -- https://gist.github.com/btbytes/7159902
109026
+ WHILE new_id_int != 0 LOOP
109027
+ new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
109028
+ new_id_int := new_id_int / alphabet_length;
109029
+ END LOOP;
109030
+
109031
+ done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
109032
+ END LOOP;
109033
+ RETURN new_id_str;
109034
+ END;
109035
+ $function$
109036
+ 
109037
+  (0.2ms) DROP TABLE IF EXISTS "kithe_derivatives" CASCADE
109038
+  (20.0ms) CREATE TABLE "kithe_derivatives" ("id" bigserial primary key, "key" character varying NOT NULL, "file_data" jsonb, "asset_id" uuid NOT NULL, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
109039
+  (1.8ms) CREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")
109040
+  (1.2ms) CREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")
109041
+  (0.2ms) DROP TABLE IF EXISTS "kithe_model_contains" CASCADE
109042
+  (8.4ms) CREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid)
109043
+  (11.8ms) CREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")
109044
+  (1.3ms) CREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")
109045
+  (0.3ms) DROP TABLE IF EXISTS "kithe_models" CASCADE
109046
+  (4.1ms) CREATE TABLE "kithe_models" ("id" uuid DEFAULT gen_random_uuid() NOT NULL PRIMARY KEY, "title" character varying NOT NULL, "type" character varying NOT NULL, "position" integer, "json_attributes" jsonb, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL, "parent_id" uuid, "friendlier_id" character varying DEFAULT kithe_models_friendlier_id_gen('2821109907456'::bigint, '101559956668415'::bigint) NOT NULL, "file_data" jsonb, "representative_id" uuid, "leaf_representative_id" uuid, "kithe_model_type" integer NOT NULL)
109047
+  (1.6ms) CREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")
109048
+  (1.4ms) CREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")
109049
+  (2.2ms) CREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")
109050
+  (1.9ms) CREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")
109051
+  (4.3ms) ALTER TABLE "kithe_derivatives" ADD CONSTRAINT "fk_rails_3dac8b4201"
109052
+ FOREIGN KEY ("asset_id")
109053
+ REFERENCES "kithe_models" ("id")
109054
+ 
109055
+  (2.0ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_490c1158f7"
109056
+ FOREIGN KEY ("containee_id")
109057
+ REFERENCES "kithe_models" ("id")
109058
+ 
109059
+  (2.1ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_091010187b"
109060
+ FOREIGN KEY ("container_id")
109061
+ REFERENCES "kithe_models" ("id")
109062
+ 
109063
+  (2.0ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
109064
+ FOREIGN KEY ("leaf_representative_id")
109065
+ REFERENCES "kithe_models" ("id")
109066
+ 
109067
+  (1.8ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
109068
+ FOREIGN KEY ("parent_id")
109069
+ REFERENCES "kithe_models" ("id")
109070
+ 
109071
+  (1.9ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
109072
+ FOREIGN KEY ("representative_id")
109073
+ REFERENCES "kithe_models" ("id")
109074
+ 
109075
+  (3.4ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)
109076
+  (1.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
109077
+  (0.9ms) INSERT INTO "schema_migrations" (version) VALUES (20190404144551)
109078
+  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES
109079
+ (20181015143259),
109080
+ (20181015143413),
109081
+ (20181015143737),
109082
+ (20181031190647),
109083
+ (20181128185658),
109084
+ (20190103144947),
109085
+ (20190109192252);
109086
+
109087
+ 
109088
+  (21.8ms) CREATE TABLE "ar_internal_metadata" ("key" character varying NOT NULL PRIMARY KEY, "value" character varying, "created_at" timestamp(6) NOT NULL, "updated_at" timestamp(6) NOT NULL)
109089
+ ActiveRecord::InternalMetadata Load (0.6ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
109090
+  (0.2ms) BEGIN
109091
+ ActiveRecord::InternalMetadata Create (0.6ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "environment"], ["value", "development"], ["created_at", "2020-05-20 20:49:47.747085"], ["updated_at", "2020-05-20 20:49:47.747085"]]
109092
+  (0.3ms) COMMIT
109093
+ ActiveRecord::InternalMetadata Load (0.3ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
109094
+ ActiveRecord::InternalMetadata Load (0.5ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "schema_sha1"], ["LIMIT", 1]]
109095
+  (0.3ms) BEGIN
109096
+ ActiveRecord::InternalMetadata Create (0.3ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "schema_sha1"], ["value", "658d6ce4e52abaa31072af6cc4edca545468d72b"], ["created_at", "2020-05-20 20:49:47.755335"], ["updated_at", "2020-05-20 20:49:47.755335"]]
109097
+  (0.4ms) COMMIT
109098
+ SQL (11.5ms) CREATE EXTENSION IF NOT EXISTS "pgcrypto"
109099
+ SQL (0.2ms) CREATE EXTENSION IF NOT EXISTS "plpgsql"
109100
+  (2.1ms) CREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint)
109101
+ RETURNS text
109102
+ LANGUAGE plpgsql
109103
+ AS $function$
109104
+ DECLARE
109105
+ new_id_int bigint;
109106
+ new_id_str character varying := '';
109107
+ done bool;
109108
+ tries integer;
109109
+ alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
109110
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
109111
+ 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
109112
+ alphabet_length integer := array_length(alphabet, 1);
109113
+
109114
+ BEGIN
109115
+ done := false;
109116
+ tries := 0;
109117
+ WHILE (NOT done) LOOP
109118
+ tries := tries + 1;
109119
+ IF (tries > 3) THEN
109120
+ RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
109121
+ END IF;
109122
+
109123
+ new_id_int := trunc(random() * (max_value - min_value) + min_value);
109124
+
109125
+ -- convert bigint to a Base-36 alphanumeric string
109126
+ -- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
109127
+ -- https://gist.github.com/btbytes/7159902
109128
+ WHILE new_id_int != 0 LOOP
109129
+ new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
109130
+ new_id_int := new_id_int / alphabet_length;
109131
+ END LOOP;
109132
+
109133
+ done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
109134
+ END LOOP;
109135
+ RETURN new_id_str;
109136
+ END;
109137
+ $function$
109138
+ 
109139
+  (0.3ms) DROP TABLE IF EXISTS "kithe_derivatives" CASCADE
109140
+  (6.0ms) CREATE TABLE "kithe_derivatives" ("id" bigserial primary key, "key" character varying NOT NULL, "file_data" jsonb, "asset_id" uuid NOT NULL, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
109141
+  (1.9ms) CREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")
109142
+  (1.3ms) CREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")
109143
+  (0.2ms) DROP TABLE IF EXISTS "kithe_model_contains" CASCADE
109144
+  (1.1ms) CREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid)
109145
+  (2.5ms) CREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")
109146
+  (1.2ms) CREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")
109147
+  (0.2ms) DROP TABLE IF EXISTS "kithe_models" CASCADE
109148
+  (5.5ms) CREATE TABLE "kithe_models" ("id" uuid DEFAULT gen_random_uuid() NOT NULL PRIMARY KEY, "title" character varying NOT NULL, "type" character varying NOT NULL, "position" integer, "json_attributes" jsonb, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL, "parent_id" uuid, "friendlier_id" character varying DEFAULT kithe_models_friendlier_id_gen('2821109907456'::bigint, '101559956668415'::bigint) NOT NULL, "file_data" jsonb, "representative_id" uuid, "leaf_representative_id" uuid, "kithe_model_type" integer NOT NULL)
109149
+  (1.7ms) CREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")
109150
+  (2.0ms) CREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")
109151
+  (1.6ms) CREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")
109152
+  (1.2ms) CREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")
109153
+  (2.9ms) ALTER TABLE "kithe_derivatives" ADD CONSTRAINT "fk_rails_3dac8b4201"
109154
+ FOREIGN KEY ("asset_id")
109155
+ REFERENCES "kithe_models" ("id")
109156
+ 
109157
+  (1.6ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_490c1158f7"
109158
+ FOREIGN KEY ("containee_id")
109159
+ REFERENCES "kithe_models" ("id")
109160
+ 
109161
+  (1.9ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_091010187b"
109162
+ FOREIGN KEY ("container_id")
109163
+ REFERENCES "kithe_models" ("id")
109164
+ 
109165
+  (2.9ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
109166
+ FOREIGN KEY ("leaf_representative_id")
109167
+ REFERENCES "kithe_models" ("id")
109168
+ 
109169
+  (2.3ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
109170
+ FOREIGN KEY ("parent_id")
109171
+ REFERENCES "kithe_models" ("id")
109172
+ 
109173
+  (2.6ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
109174
+ FOREIGN KEY ("representative_id")
109175
+ REFERENCES "kithe_models" ("id")
109176
+ 
109177
+  (3.7ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)
109178
+  (0.6ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
109179
+  (0.7ms) INSERT INTO "schema_migrations" (version) VALUES (20190404144551)
109180
+  (0.6ms) INSERT INTO "schema_migrations" (version) VALUES
109181
+ (20181015143259),
109182
+ (20181015143413),
109183
+ (20181015143737),
109184
+ (20181031190647),
109185
+ (20181128185658),
109186
+ (20190103144947),
109187
+ (20190109192252);
109188
+
109189
+ 
109190
+  (3.0ms) CREATE TABLE "ar_internal_metadata" ("key" character varying NOT NULL PRIMARY KEY, "value" character varying, "created_at" timestamp(6) NOT NULL, "updated_at" timestamp(6) NOT NULL)
109191
+ ActiveRecord::InternalMetadata Load (0.4ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
109192
+  (0.1ms) BEGIN
109193
+ ActiveRecord::InternalMetadata Create (0.5ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "environment"], ["value", "development"], ["created_at", "2020-05-20 20:49:47.932037"], ["updated_at", "2020-05-20 20:49:47.932037"]]
109194
+  (0.5ms) COMMIT
109195
+ ActiveRecord::InternalMetadata Load (0.3ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
109196
+  (0.2ms) BEGIN
109197
+ ActiveRecord::InternalMetadata Update (0.7ms) UPDATE "ar_internal_metadata" SET "value" = $1, "updated_at" = $2 WHERE "ar_internal_metadata"."key" = $3 [["value", "test"], ["updated_at", "2020-05-20 20:49:47.940151"], ["key", "environment"]]
109198
+  (5.7ms) COMMIT
109199
+ ActiveRecord::InternalMetadata Load (0.3ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "schema_sha1"], ["LIMIT", 1]]
109200
+  (0.2ms) BEGIN
109201
+ ActiveRecord::InternalMetadata Create (0.3ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "schema_sha1"], ["value", "658d6ce4e52abaa31072af6cc4edca545468d72b"], ["created_at", "2020-05-20 20:49:47.953802"], ["updated_at", "2020-05-20 20:49:47.953802"]]
109202
+  (6.4ms) COMMIT
109203
+  (7.4ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
109204
+  (30.7ms)  SELECT
109205
+ pp.proname AS name,
109206
+ pg_get_functiondef(pp.oid) AS definition
109207
+ FROM pg_proc pp
109208
+ JOIN pg_namespace pn
109209
+ ON pn.oid = pp.pronamespace
109210
+ LEFT JOIN pg_depend pd
109211
+ ON pd.objid = pp.oid AND pd.deptype = 'e'
109212
+ WHERE pn.nspname = 'public' AND pd.objid IS NULL
109213
+ ORDER BY pp.oid;
109214
+ 
109215
+  (1.8ms)  SELECT
109216
+ pt.tgname AS name,
109217
+ pg_get_triggerdef(pt.oid) AS definition
109218
+ FROM pg_trigger pt
109219
+ JOIN pg_class pc
109220
+ ON (pc.oid = pt.tgrelid)
109221
+ JOIN pg_proc pp
109222
+ ON (pp.oid = pt.tgfoid)
109223
+ WHERE pt.tgname
109224
+ NOT ILIKE '%constraint%' AND pt.tgname NOT ILIKE 'pg%'
109225
+ ORDER BY pc.oid;
109226
+ 
109227
+  (1.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
109228
+  (4.5ms)  SELECT
109229
+ pp.proname AS name,
109230
+ pg_get_functiondef(pp.oid) AS definition
109231
+ FROM pg_proc pp
109232
+ JOIN pg_namespace pn
109233
+ ON pn.oid = pp.pronamespace
109234
+ LEFT JOIN pg_depend pd
109235
+ ON pd.objid = pp.oid AND pd.deptype = 'e'
109236
+ WHERE pn.nspname = 'public' AND pd.objid IS NULL
109237
+ ORDER BY pp.oid;
109238
+ 
109239
+  (2.0ms)  SELECT
109240
+ pt.tgname AS name,
109241
+ pg_get_triggerdef(pt.oid) AS definition
109242
+ FROM pg_trigger pt
109243
+ JOIN pg_class pc
109244
+ ON (pc.oid = pt.tgrelid)
109245
+ JOIN pg_proc pp
109246
+ ON (pp.oid = pt.tgfoid)
109247
+ WHERE pt.tgname
109248
+ NOT ILIKE '%constraint%' AND pt.tgname NOT ILIKE 'pg%'
109249
+ ORDER BY pc.oid;
109250
+ 
109251
+  (1.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
109252
+  (4.2ms)  SELECT
109253
+ pp.proname AS name,
109254
+ pg_get_functiondef(pp.oid) AS definition
109255
+ FROM pg_proc pp
109256
+ JOIN pg_namespace pn
109257
+ ON pn.oid = pp.pronamespace
109258
+ LEFT JOIN pg_depend pd
109259
+ ON pd.objid = pp.oid AND pd.deptype = 'e'
109260
+ WHERE pn.nspname = 'public' AND pd.objid IS NULL
109261
+ ORDER BY pp.oid;
109262
+ 
109263
+  (1.4ms)  SELECT
109264
+ pt.tgname AS name,
109265
+ pg_get_triggerdef(pt.oid) AS definition
109266
+ FROM pg_trigger pt
109267
+ JOIN pg_class pc
109268
+ ON (pc.oid = pt.tgrelid)
109269
+ JOIN pg_proc pp
109270
+ ON (pp.oid = pt.tgfoid)
109271
+ WHERE pt.tgname
109272
+ NOT ILIKE '%constraint%' AND pt.tgname NOT ILIKE 'pg%'
109273
+ ORDER BY pc.oid;
109274
+ 
109275
+  (1.2ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
109276
+  (4.4ms)  SELECT
109277
+ pp.proname AS name,
109278
+ pg_get_functiondef(pp.oid) AS definition
109279
+ FROM pg_proc pp
109280
+ JOIN pg_namespace pn
109281
+ ON pn.oid = pp.pronamespace
109282
+ LEFT JOIN pg_depend pd
109283
+ ON pd.objid = pp.oid AND pd.deptype = 'e'
109284
+ WHERE pn.nspname = 'public' AND pd.objid IS NULL
109285
+ ORDER BY pp.oid;
109286
+ 
109287
+  (1.4ms)  SELECT
109288
+ pt.tgname AS name,
109289
+ pg_get_triggerdef(pt.oid) AS definition
109290
+ FROM pg_trigger pt
109291
+ JOIN pg_class pc
109292
+ ON (pc.oid = pt.tgrelid)
109293
+ JOIN pg_proc pp
109294
+ ON (pp.oid = pt.tgfoid)
109295
+ WHERE pt.tgname
109296
+ NOT ILIKE '%constraint%' AND pt.tgname NOT ILIKE 'pg%'
109297
+ ORDER BY pc.oid;
109298
+ 
109299
+  (0.9ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
109300
+  (4.2ms)  SELECT
109301
+ pp.proname AS name,
109302
+ pg_get_functiondef(pp.oid) AS definition
109303
+ FROM pg_proc pp
109304
+ JOIN pg_namespace pn
109305
+ ON pn.oid = pp.pronamespace
109306
+ LEFT JOIN pg_depend pd
109307
+ ON pd.objid = pp.oid AND pd.deptype = 'e'
109308
+ WHERE pn.nspname = 'public' AND pd.objid IS NULL
109309
+ ORDER BY pp.oid;
109310
+ 
109311
+  (1.3ms)  SELECT
109312
+ pt.tgname AS name,
109313
+ pg_get_triggerdef(pt.oid) AS definition
109314
+ FROM pg_trigger pt
109315
+ JOIN pg_class pc
109316
+ ON (pc.oid = pt.tgrelid)
109317
+ JOIN pg_proc pp
109318
+ ON (pp.oid = pt.tgfoid)
109319
+ WHERE pt.tgname
109320
+ NOT ILIKE '%constraint%' AND pt.tgname NOT ILIKE 'pg%'
109321
+ ORDER BY pc.oid;
109322
+ 
109323
+  (0.8ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
109324
+  (0.5ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
109325
+  (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
109326
+  (0.2ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
109327
+  (0.4ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
109328
+  (0.2ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
109329
+  (216.4ms) DROP DATABASE IF EXISTS "kithe_development"
109330
+  (228.1ms) DROP DATABASE IF EXISTS "kithe_test"
109331
+  (494.0ms) CREATE DATABASE "kithe_development" ENCODING = 'unicode'
109332
+  (422.6ms) CREATE DATABASE "kithe_test" ENCODING = 'unicode'
109333
+ SQL (63.2ms) CREATE EXTENSION IF NOT EXISTS "pgcrypto"
109334
+ SQL (50.2ms) CREATE EXTENSION IF NOT EXISTS "plpgsql"
109335
+  (34.8ms) CREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint)
109336
+ RETURNS text
109337
+ LANGUAGE plpgsql
109338
+ AS $function$
109339
+ DECLARE
109340
+ new_id_int bigint;
109341
+ new_id_str character varying := '';
109342
+ done bool;
109343
+ tries integer;
109344
+ alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
109345
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
109346
+ 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
109347
+ alphabet_length integer := array_length(alphabet, 1);
109348
+
109349
+ BEGIN
109350
+ done := false;
109351
+ tries := 0;
109352
+ WHILE (NOT done) LOOP
109353
+ tries := tries + 1;
109354
+ IF (tries > 3) THEN
109355
+ RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
109356
+ END IF;
109357
+
109358
+ new_id_int := trunc(random() * (max_value - min_value) + min_value);
109359
+
109360
+ -- convert bigint to a Base-36 alphanumeric string
109361
+ -- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
109362
+ -- https://gist.github.com/btbytes/7159902
109363
+ WHILE new_id_int != 0 LOOP
109364
+ new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
109365
+ new_id_int := new_id_int / alphabet_length;
109366
+ END LOOP;
109367
+
109368
+ done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
109369
+ END LOOP;
109370
+ RETURN new_id_str;
109371
+ END;
109372
+ $function$
109373
+ 
109374
+  (0.4ms) DROP TABLE IF EXISTS "kithe_derivatives" CASCADE
109375
+  (12.8ms) CREATE TABLE "kithe_derivatives" ("id" bigserial primary key, "key" character varying NOT NULL, "file_data" jsonb, "asset_id" uuid NOT NULL, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
109376
+  (2.0ms) CREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")
109377
+  (1.5ms) CREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")
109378
+  (0.2ms) DROP TABLE IF EXISTS "kithe_model_contains" CASCADE
109379
+  (1.1ms) CREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid)
109380
+  (1.1ms) CREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")
109381
+  (1.3ms) CREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")
109382
+  (0.4ms) DROP TABLE IF EXISTS "kithe_models" CASCADE
109383
+  (4.4ms) CREATE TABLE "kithe_models" ("id" uuid DEFAULT gen_random_uuid() NOT NULL PRIMARY KEY, "title" character varying NOT NULL, "type" character varying NOT NULL, "position" integer, "json_attributes" jsonb, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL, "parent_id" uuid, "friendlier_id" character varying DEFAULT kithe_models_friendlier_id_gen('2821109907456'::bigint, '101559956668415'::bigint) NOT NULL, "file_data" jsonb, "representative_id" uuid, "leaf_representative_id" uuid, "kithe_model_type" integer NOT NULL)
109384
+  (1.3ms) CREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")
109385
+  (1.3ms) CREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")
109386
+  (1.1ms) CREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")
109387
+  (1.1ms) CREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")
109388
+  (3.2ms) ALTER TABLE "kithe_derivatives" ADD CONSTRAINT "fk_rails_3dac8b4201"
109389
+ FOREIGN KEY ("asset_id")
109390
+ REFERENCES "kithe_models" ("id")
109391
+ 
109392
+  (2.3ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_490c1158f7"
109393
+ FOREIGN KEY ("containee_id")
109394
+ REFERENCES "kithe_models" ("id")
109395
+ 
109396
+  (1.7ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_091010187b"
109397
+ FOREIGN KEY ("container_id")
109398
+ REFERENCES "kithe_models" ("id")
109399
+ 
109400
+  (1.6ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
109401
+ FOREIGN KEY ("leaf_representative_id")
109402
+ REFERENCES "kithe_models" ("id")
109403
+ 
109404
+  (1.7ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
109405
+ FOREIGN KEY ("parent_id")
109406
+ REFERENCES "kithe_models" ("id")
109407
+ 
109408
+  (1.7ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
109409
+ FOREIGN KEY ("representative_id")
109410
+ REFERENCES "kithe_models" ("id")
109411
+ 
109412
+  (7.6ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)
109413
+  (0.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
109414
+  (0.7ms) INSERT INTO "schema_migrations" (version) VALUES (20190404144551)
109415
+  (0.6ms) INSERT INTO "schema_migrations" (version) VALUES
109416
+ (20181015143259),
109417
+ (20181015143413),
109418
+ (20181015143737),
109419
+ (20181031190647),
109420
+ (20181128185658),
109421
+ (20190103144947),
109422
+ (20190109192252);
109423
+
109424
+ 
109425
+  (3.8ms) CREATE TABLE "ar_internal_metadata" ("key" character varying NOT NULL PRIMARY KEY, "value" character varying, "created_at" timestamp(6) NOT NULL, "updated_at" timestamp(6) NOT NULL)
109426
+ ActiveRecord::InternalMetadata Load (0.4ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
109427
+  (0.2ms) BEGIN
109428
+ ActiveRecord::InternalMetadata Create (0.5ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "environment"], ["value", "development"], ["created_at", "2020-05-20 21:22:55.681291"], ["updated_at", "2020-05-20 21:22:55.681291"]]
109429
+  (0.5ms) COMMIT
109430
+ ActiveRecord::InternalMetadata Load (0.2ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
109431
+ ActiveRecord::InternalMetadata Load (0.3ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "schema_sha1"], ["LIMIT", 1]]
109432
+  (0.1ms) BEGIN
109433
+ ActiveRecord::InternalMetadata Create (0.3ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "schema_sha1"], ["value", "0e24e2caa948e64f3be11233d707b8abffa0f356"], ["created_at", "2020-05-20 21:22:55.690278"], ["updated_at", "2020-05-20 21:22:55.690278"]]
109434
+  (0.5ms) COMMIT
109435
+ SQL (10.7ms) CREATE EXTENSION IF NOT EXISTS "pgcrypto"
109436
+ SQL (0.2ms) CREATE EXTENSION IF NOT EXISTS "plpgsql"
109437
+  (2.1ms) CREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint)
109438
+ RETURNS text
109439
+ LANGUAGE plpgsql
109440
+ AS $function$
109441
+ DECLARE
109442
+ new_id_int bigint;
109443
+ new_id_str character varying := '';
109444
+ done bool;
109445
+ tries integer;
109446
+ alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
109447
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
109448
+ 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
109449
+ alphabet_length integer := array_length(alphabet, 1);
109450
+
109451
+ BEGIN
109452
+ done := false;
109453
+ tries := 0;
109454
+ WHILE (NOT done) LOOP
109455
+ tries := tries + 1;
109456
+ IF (tries > 3) THEN
109457
+ RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
109458
+ END IF;
109459
+
109460
+ new_id_int := trunc(random() * (max_value - min_value) + min_value);
109461
+
109462
+ -- convert bigint to a Base-36 alphanumeric string
109463
+ -- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
109464
+ -- https://gist.github.com/btbytes/7159902
109465
+ WHILE new_id_int != 0 LOOP
109466
+ new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
109467
+ new_id_int := new_id_int / alphabet_length;
109468
+ END LOOP;
109469
+
109470
+ done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
109471
+ END LOOP;
109472
+ RETURN new_id_str;
109473
+ END;
109474
+ $function$
109475
+ 
109476
+  (0.2ms) DROP TABLE IF EXISTS "kithe_derivatives" CASCADE
109477
+  (6.5ms) CREATE TABLE "kithe_derivatives" ("id" bigserial primary key, "key" character varying NOT NULL, "file_data" jsonb, "asset_id" uuid NOT NULL, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL)
109478
+  (1.7ms) CREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")
109479
+  (1.2ms) CREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")
109480
+  (0.2ms) DROP TABLE IF EXISTS "kithe_model_contains" CASCADE
109481
+  (1.0ms) CREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid)
109482
+  (1.7ms) CREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")
109483
+  (1.3ms) CREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")
109484
+  (0.2ms) DROP TABLE IF EXISTS "kithe_models" CASCADE
109485
+  (3.4ms) CREATE TABLE "kithe_models" ("id" uuid DEFAULT gen_random_uuid() NOT NULL PRIMARY KEY, "title" character varying NOT NULL, "type" character varying NOT NULL, "position" integer, "json_attributes" jsonb, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL, "parent_id" uuid, "friendlier_id" character varying DEFAULT kithe_models_friendlier_id_gen('2821109907456'::bigint, '101559956668415'::bigint) NOT NULL, "file_data" jsonb, "representative_id" uuid, "leaf_representative_id" uuid, "kithe_model_type" integer NOT NULL)
109486
+  (1.2ms) CREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")
109487
+  (1.2ms) CREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")
109488
+  (1.4ms) CREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")
109489
+  (1.2ms) CREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")
109490
+  (2.8ms) ALTER TABLE "kithe_derivatives" ADD CONSTRAINT "fk_rails_3dac8b4201"
109491
+ FOREIGN KEY ("asset_id")
109492
+ REFERENCES "kithe_models" ("id")
109493
+ 
109494
+  (1.8ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_490c1158f7"
109495
+ FOREIGN KEY ("containee_id")
109496
+ REFERENCES "kithe_models" ("id")
109497
+ 
109498
+  (1.5ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_091010187b"
109499
+ FOREIGN KEY ("container_id")
109500
+ REFERENCES "kithe_models" ("id")
109501
+ 
109502
+  (2.1ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
109503
+ FOREIGN KEY ("leaf_representative_id")
109504
+ REFERENCES "kithe_models" ("id")
109505
+ 
109506
+  (1.8ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
109507
+ FOREIGN KEY ("parent_id")
109508
+ REFERENCES "kithe_models" ("id")
109509
+ 
109510
+  (1.8ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
109511
+ FOREIGN KEY ("representative_id")
109512
+ REFERENCES "kithe_models" ("id")
109513
+ 
109514
+  (3.0ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)
109515
+  (0.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
109516
+  (1.1ms) INSERT INTO "schema_migrations" (version) VALUES (20190404144551)
109517
+  (0.6ms) INSERT INTO "schema_migrations" (version) VALUES
109518
+ (20181015143259),
109519
+ (20181015143413),
109520
+ (20181015143737),
109521
+ (20181031190647),
109522
+ (20181128185658),
109523
+ (20190103144947),
109524
+ (20190109192252);
109525
+
109526
+ 
109527
+  (2.9ms) CREATE TABLE "ar_internal_metadata" ("key" character varying NOT NULL PRIMARY KEY, "value" character varying, "created_at" timestamp(6) NOT NULL, "updated_at" timestamp(6) NOT NULL)
109528
+ ActiveRecord::InternalMetadata Load (0.4ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
109529
+  (0.1ms) BEGIN
109530
+ ActiveRecord::InternalMetadata Create (0.5ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "environment"], ["value", "development"], ["created_at", "2020-05-20 21:22:55.842211"], ["updated_at", "2020-05-20 21:22:55.842211"]]
109531
+  (0.4ms) COMMIT
109532
+ ActiveRecord::InternalMetadata Load (0.3ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]]
109533
+  (0.1ms) BEGIN
109534
+ ActiveRecord::InternalMetadata Update (0.4ms) UPDATE "ar_internal_metadata" SET "value" = $1, "updated_at" = $2 WHERE "ar_internal_metadata"."key" = $3 [["value", "test"], ["updated_at", "2020-05-20 21:22:55.848684"], ["key", "environment"]]
109535
+  (0.3ms) COMMIT
109536
+ ActiveRecord::InternalMetadata Load (0.3ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "schema_sha1"], ["LIMIT", 1]]
109537
+  (0.1ms) BEGIN
109538
+ ActiveRecord::InternalMetadata Create (0.3ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "schema_sha1"], ["value", "0e24e2caa948e64f3be11233d707b8abffa0f356"], ["created_at", "2020-05-20 21:22:55.854305"], ["updated_at", "2020-05-20 21:22:55.854305"]]
109539
+  (0.4ms) COMMIT