spec/dummy/log/development.log in kithe-2.0.1 vs spec/dummy/log/development.log in kithe-2.0.2

- old
+ new

@@ -111538,5 +111538,751 @@ 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]]  (0.2ms) BEGIN 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-28 13:26:55.668516"], ["updated_at", "2020-05-28 13:26:55.668516"]]  (0.5ms) COMMIT  (1.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC +  (2.9ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC +  (0.6ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]] +  (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC +  (0.3ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]] +  (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC +  (0.2ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]] +  (1.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC +  (0.6ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]] +  (0.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC +  (0.3ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]] +  (0.4ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC +  (0.3ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]] + SQL (38.3ms) CREATE EXTENSION IF NOT EXISTS "pgcrypto" + SQL (0.3ms) CREATE EXTENSION IF NOT EXISTS "plpgsql" +  (32.7ms) CREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint) + RETURNS text + LANGUAGE plpgsql +AS $function$ + DECLARE + new_id_int bigint; + new_id_str character varying := ''; + done bool; + tries integer; + alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']; + alphabet_length integer := array_length(alphabet, 1); + + BEGIN + done := false; + tries := 0; + WHILE (NOT done) LOOP + tries := tries + 1; + IF (tries > 3) THEN + RAISE 'Could not find non-conflicting friendlier_id in 3 tries'; + END IF; + + new_id_int := trunc(random() * (max_value - min_value) + min_value); + + -- convert bigint to a Base-36 alphanumeric string + -- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/ + -- https://gist.github.com/btbytes/7159902 + WHILE new_id_int != 0 LOOP + new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str; + new_id_int := new_id_int / alphabet_length; + END LOOP; + + done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str); + END LOOP; + RETURN new_id_str; + END; + $function$ + +  (45.1ms) DROP TABLE IF EXISTS "kithe_derivatives" CASCADE +  (50.4ms) 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) +  (1.8ms) CREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key") +  (1.5ms) CREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id") +  (3.6ms) DROP TABLE IF EXISTS "kithe_model_contains" CASCADE +  (4.5ms) CREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid) +  (2.0ms) CREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id") +  (1.7ms) CREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id") +  (7.3ms) DROP TABLE IF EXISTS "kithe_models" CASCADE +  (12.2ms) 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) +  (1.3ms) CREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id") +  (1.8ms) CREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id") +  (1.3ms) CREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id") +  (1.2ms) CREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id") +  (8.9ms) CREATE TABLE "plain_old_ar" ("id" bigserial primary key, "title" character varying, "description" text) +  (6.3ms) ALTER TABLE "kithe_derivatives" ADD CONSTRAINT "fk_rails_3dac8b4201" +FOREIGN KEY ("asset_id") + REFERENCES "kithe_models" ("id") + +  (3.9ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_490c1158f7" +FOREIGN KEY ("containee_id") + REFERENCES "kithe_models" ("id") + +  (2.8ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_091010187b" +FOREIGN KEY ("container_id") + REFERENCES "kithe_models" ("id") + +  (1.8ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d" +FOREIGN KEY ("leaf_representative_id") + REFERENCES "kithe_models" ("id") + +  (3.4ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780" +FOREIGN KEY ("parent_id") + REFERENCES "kithe_models" ("id") + +  (1.9ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d" +FOREIGN KEY ("representative_id") + REFERENCES "kithe_models" ("id") + +  (0.8ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC + 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]] + 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]] + 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]] +  (0.2ms) BEGIN + ActiveRecord::InternalMetadata Update (0.5ms) UPDATE "ar_internal_metadata" SET "value" = $1, "updated_at" = $2 WHERE "ar_internal_metadata"."key" = $3 [["value", "03c1babae3d781ef770d42f3017561a4fadf7200"], ["updated_at", "2020-06-04 16:46:18.145376"], ["key", "schema_sha1"]] +  (0.4ms) COMMIT + SQL (2.6ms) CREATE EXTENSION IF NOT EXISTS "pgcrypto" + SQL (0.5ms) CREATE EXTENSION IF NOT EXISTS "plpgsql" +  (28.9ms) CREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint) + RETURNS text + LANGUAGE plpgsql +AS $function$ + DECLARE + new_id_int bigint; + new_id_str character varying := ''; + done bool; + tries integer; + alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']; + alphabet_length integer := array_length(alphabet, 1); + + BEGIN + done := false; + tries := 0; + WHILE (NOT done) LOOP + tries := tries + 1; + IF (tries > 3) THEN + RAISE 'Could not find non-conflicting friendlier_id in 3 tries'; + END IF; + + new_id_int := trunc(random() * (max_value - min_value) + min_value); + + -- convert bigint to a Base-36 alphanumeric string + -- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/ + -- https://gist.github.com/btbytes/7159902 + WHILE new_id_int != 0 LOOP + new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str; + new_id_int := new_id_int / alphabet_length; + END LOOP; + + done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str); + END LOOP; + RETURN new_id_str; + END; + $function$ + +  (29.1ms) DROP TABLE IF EXISTS "kithe_derivatives" CASCADE +  (24.3ms) 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) +  (2.2ms) CREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key") +  (1.3ms) CREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id") +  (2.7ms) DROP TABLE IF EXISTS "kithe_model_contains" CASCADE +  (1.3ms) CREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid) +  (1.3ms) CREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id") +  (1.3ms) CREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id") +  (6.6ms) DROP TABLE IF EXISTS "kithe_models" CASCADE +  (5.2ms) 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) +  (1.5ms) CREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id") +  (1.3ms) CREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id") +  (1.3ms) CREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id") +  (1.3ms) CREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id") +  (4.5ms) CREATE TABLE "plain_old_ar" ("id" bigserial primary key, "title" character varying, "description" text) +  (6.6ms) ALTER TABLE "kithe_derivatives" ADD CONSTRAINT "fk_rails_3dac8b4201" +FOREIGN KEY ("asset_id") + REFERENCES "kithe_models" ("id") + +  (2.0ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_490c1158f7" +FOREIGN KEY ("containee_id") + REFERENCES "kithe_models" ("id") + +  (1.7ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_091010187b" +FOREIGN KEY ("container_id") + REFERENCES "kithe_models" ("id") + +  (1.8ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d" +FOREIGN KEY ("leaf_representative_id") + REFERENCES "kithe_models" ("id") + +  (1.7ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780" +FOREIGN KEY ("parent_id") + REFERENCES "kithe_models" ("id") + +  (1.8ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d" +FOREIGN KEY ("representative_id") + REFERENCES "kithe_models" ("id") + +  (1.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC + 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]] +  (0.2ms) BEGIN + ActiveRecord::InternalMetadata Update (0.5ms) UPDATE "ar_internal_metadata" SET "value" = $1, "updated_at" = $2 WHERE "ar_internal_metadata"."key" = $3 [["value", "development"], ["updated_at", "2020-06-04 16:46:18.411648"], ["key", "environment"]] +  (0.5ms) COMMIT + 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]] +  (0.2ms) BEGIN + ActiveRecord::InternalMetadata Update (0.5ms) UPDATE "ar_internal_metadata" SET "value" = $1, "updated_at" = $2 WHERE "ar_internal_metadata"."key" = $3 [["value", "test"], ["updated_at", "2020-06-04 16:46:18.418618"], ["key", "environment"]] +  (0.4ms) COMMIT + ActiveRecord::InternalMetadata Load (0.4ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "schema_sha1"], ["LIMIT", 1]] +  (0.2ms) BEGIN + ActiveRecord::InternalMetadata Update (0.4ms) UPDATE "ar_internal_metadata" SET "value" = $1, "updated_at" = $2 WHERE "ar_internal_metadata"."key" = $3 [["value", "03c1babae3d781ef770d42f3017561a4fadf7200"], ["updated_at", "2020-06-04 16:46:18.423797"], ["key", "schema_sha1"]] +  (0.5ms) COMMIT +  (1.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC +  (0.6ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]] +  (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC +  (0.3ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]] +  (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC +  (0.3ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]] +  (340.9ms) DROP DATABASE IF EXISTS "kithe_development" +  (224.9ms) DROP DATABASE IF EXISTS "kithe_test" +  (701.4ms) CREATE DATABASE "kithe_development" ENCODING = 'unicode' +  (483.4ms) CREATE DATABASE "kithe_test" ENCODING = 'unicode' + SQL (182.5ms) CREATE EXTENSION IF NOT EXISTS "pgcrypto" + SQL (0.2ms) CREATE EXTENSION IF NOT EXISTS "plpgsql" +  (2.2ms) CREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint) + RETURNS text + LANGUAGE plpgsql +AS $function$ + DECLARE + new_id_int bigint; + new_id_str character varying := ''; + done bool; + tries integer; + alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']; + alphabet_length integer := array_length(alphabet, 1); + + BEGIN + done := false; + tries := 0; + WHILE (NOT done) LOOP + tries := tries + 1; + IF (tries > 3) THEN + RAISE 'Could not find non-conflicting friendlier_id in 3 tries'; + END IF; + + new_id_int := trunc(random() * (max_value - min_value) + min_value); + + -- convert bigint to a Base-36 alphanumeric string + -- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/ + -- https://gist.github.com/btbytes/7159902 + WHILE new_id_int != 0 LOOP + new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str; + new_id_int := new_id_int / alphabet_length; + END LOOP; + + done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str); + END LOOP; + RETURN new_id_str; + END; + $function$ + +  (0.2ms) DROP TABLE IF EXISTS "kithe_derivatives" CASCADE +  (10.4ms) 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) +  (2.6ms) CREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key") +  (1.2ms) CREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id") +  (0.2ms) DROP TABLE IF EXISTS "kithe_model_contains" CASCADE +  (1.7ms) CREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid) +  (1.2ms) CREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id") +  (1.3ms) CREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id") +  (0.3ms) DROP TABLE IF EXISTS "kithe_models" CASCADE +  (4.2ms) 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) +  (1.3ms) CREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id") +  (1.3ms) CREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id") +  (1.5ms) CREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id") +  (1.3ms) CREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id") +  (8.7ms) CREATE TABLE "plain_old_ars" ("id" bigserial primary key, "title" character varying, "description" text) +  (3.4ms) ALTER TABLE "kithe_derivatives" ADD CONSTRAINT "fk_rails_3dac8b4201" +FOREIGN KEY ("asset_id") + REFERENCES "kithe_models" ("id") + +  (1.8ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_490c1158f7" +FOREIGN KEY ("containee_id") + REFERENCES "kithe_models" ("id") + +  (1.8ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_091010187b" +FOREIGN KEY ("container_id") + REFERENCES "kithe_models" ("id") + +  (1.8ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d" +FOREIGN KEY ("leaf_representative_id") + REFERENCES "kithe_models" ("id") + +  (1.7ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780" +FOREIGN KEY ("parent_id") + REFERENCES "kithe_models" ("id") + +  (1.7ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d" +FOREIGN KEY ("representative_id") + REFERENCES "kithe_models" ("id") + +  (3.8ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY) +  (0.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC +  (5.9ms) INSERT INTO "schema_migrations" (version) VALUES (20190404144551) +  (21.1ms) INSERT INTO "schema_migrations" (version) VALUES +(20181015143259), +(20181015143413), +(20181015143737), +(20181031190647), +(20181128185658), +(20190103144947), +(20190109192252); + + +  (3.3ms) 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) + ActiveRecord::InternalMetadata Load (1.3ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]] +  (0.7ms) BEGIN + 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-06-04 16:47:04.539998"], ["updated_at", "2020-06-04 16:47:04.539998"]] +  (0.5ms) COMMIT + 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]] + ActiveRecord::InternalMetadata Load (1.2ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "schema_sha1"], ["LIMIT", 1]] +  (0.2ms) BEGIN + ActiveRecord::InternalMetadata Create (0.4ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "schema_sha1"], ["value", "6d88defc9e286449197e3c57b6342e1510b872dd"], ["created_at", "2020-06-04 16:47:04.552438"], ["updated_at", "2020-06-04 16:47:04.552438"]] +  (0.4ms) COMMIT + SQL (15.3ms) CREATE EXTENSION IF NOT EXISTS "pgcrypto" + SQL (0.2ms) CREATE EXTENSION IF NOT EXISTS "plpgsql" +  (2.5ms) CREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint) + RETURNS text + LANGUAGE plpgsql +AS $function$ + DECLARE + new_id_int bigint; + new_id_str character varying := ''; + done bool; + tries integer; + alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']; + alphabet_length integer := array_length(alphabet, 1); + + BEGIN + done := false; + tries := 0; + WHILE (NOT done) LOOP + tries := tries + 1; + IF (tries > 3) THEN + RAISE 'Could not find non-conflicting friendlier_id in 3 tries'; + END IF; + + new_id_int := trunc(random() * (max_value - min_value) + min_value); + + -- convert bigint to a Base-36 alphanumeric string + -- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/ + -- https://gist.github.com/btbytes/7159902 + WHILE new_id_int != 0 LOOP + new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str; + new_id_int := new_id_int / alphabet_length; + END LOOP; + + done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str); + END LOOP; + RETURN new_id_str; + END; + $function$ + +  (0.2ms) DROP TABLE IF EXISTS "kithe_derivatives" CASCADE +  (11.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) +  (1.8ms) CREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key") +  (1.2ms) CREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id") +  (0.2ms) DROP TABLE IF EXISTS "kithe_model_contains" CASCADE +  (1.2ms) CREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid) +  (1.2ms) CREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id") +  (1.2ms) CREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id") +  (0.4ms) DROP TABLE IF EXISTS "kithe_models" CASCADE +  (3.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, "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) +  (1.7ms) CREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id") +  (1.3ms) CREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id") +  (1.2ms) CREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id") +  (1.1ms) CREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id") +  (4.5ms) CREATE TABLE "plain_old_ars" ("id" bigserial primary key, "title" character varying, "description" text) +  (6.5ms) ALTER TABLE "kithe_derivatives" ADD CONSTRAINT "fk_rails_3dac8b4201" +FOREIGN KEY ("asset_id") + REFERENCES "kithe_models" ("id") + +  (2.1ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_490c1158f7" +FOREIGN KEY ("containee_id") + REFERENCES "kithe_models" ("id") + +  (1.7ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_091010187b" +FOREIGN KEY ("container_id") + REFERENCES "kithe_models" ("id") + +  (3.1ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d" +FOREIGN KEY ("leaf_representative_id") + REFERENCES "kithe_models" ("id") + +  (19.0ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780" +FOREIGN KEY ("parent_id") + REFERENCES "kithe_models" ("id") + +  (7.7ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d" +FOREIGN KEY ("representative_id") + REFERENCES "kithe_models" ("id") + +  (7.0ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY) +  (0.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC +  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES (20190404144551) +  (0.6ms) INSERT INTO "schema_migrations" (version) VALUES +(20181015143259), +(20181015143413), +(20181015143737), +(20181031190647), +(20181128185658), +(20190103144947), +(20190109192252); + + +  (4.1ms) 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) + ActiveRecord::InternalMetadata Load (1.0ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "environment"], ["LIMIT", 1]] +  (0.2ms) BEGIN + ActiveRecord::InternalMetadata Create (0.8ms) 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-06-04 16:47:04.783078"], ["updated_at", "2020-06-04 16:47:04.783078"]] +  (0.4ms) COMMIT + 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]] +  (0.1ms) BEGIN + 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-06-04 16:47:04.789820"], ["key", "environment"]] +  (0.4ms) COMMIT + 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]] +  (0.1ms) BEGIN + ActiveRecord::InternalMetadata Create (0.4ms) INSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key" [["key", "schema_sha1"], ["value", "6d88defc9e286449197e3c57b6342e1510b872dd"], ["created_at", "2020-06-04 16:47:04.795239"], ["updated_at", "2020-06-04 16:47:04.795239"]] +  (0.4ms) COMMIT +  (0.9ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC + PlainOldAr Load (0.4ms) SELECT "plain_old_ars".* FROM "plain_old_ars" ORDER BY "plain_old_ars"."id" ASC LIMIT $1 [["LIMIT", 1]] +  (1.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC +  (0.4ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]] +  (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC +  (0.3ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]] +  (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC +  (0.2ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]] +  (227.8ms) DROP DATABASE IF EXISTS "kithe_development" +  (217.1ms) DROP DATABASE IF EXISTS "kithe_test" +  (496.1ms) CREATE DATABASE "kithe_development" ENCODING = 'unicode' +  (495.5ms) CREATE DATABASE "kithe_test" ENCODING = 'unicode' + SQL (25.2ms) CREATE EXTENSION IF NOT EXISTS "pgcrypto" + SQL (0.3ms) CREATE EXTENSION IF NOT EXISTS "plpgsql" +  (23.8ms) CREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint) + RETURNS text + LANGUAGE plpgsql +AS $function$ + DECLARE + new_id_int bigint; + new_id_str character varying := ''; + done bool; + tries integer; + alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']; + alphabet_length integer := array_length(alphabet, 1); + + BEGIN + done := false; + tries := 0; + WHILE (NOT done) LOOP + tries := tries + 1; + IF (tries > 3) THEN + RAISE 'Could not find non-conflicting friendlier_id in 3 tries'; + END IF; + + new_id_int := trunc(random() * (max_value - min_value) + min_value); + + -- convert bigint to a Base-36 alphanumeric string + -- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/ + -- https://gist.github.com/btbytes/7159902 + WHILE new_id_int != 0 LOOP + new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str; + new_id_int := new_id_int / alphabet_length; + END LOOP; + + done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str); + END LOOP; + RETURN new_id_str; + END; + $function$ + +  (0.3ms) DROP TABLE IF EXISTS "kithe_derivatives" CASCADE +  (20.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) +  (2.1ms) CREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key") +  (1.1ms) CREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id") +  (0.2ms) DROP TABLE IF EXISTS "kithe_model_contains" CASCADE +  (1.1ms) CREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid) +  (1.4ms) CREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id") +  (1.1ms) CREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id") +  (0.2ms) DROP TABLE IF EXISTS "kithe_models" CASCADE +  (4.2ms) 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) +  (1.2ms) CREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id") +  (1.8ms) CREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id") +  (6.3ms) CREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id") +  (1.8ms) CREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id") +  (3.6ms) CREATE TABLE "plain_active_records" ("id" bigserial primary key, "title" character varying, "description" text) +  (3.2ms) ALTER TABLE "kithe_derivatives" ADD CONSTRAINT "fk_rails_3dac8b4201" +FOREIGN KEY ("asset_id") + REFERENCES "kithe_models" ("id") + +  (136.8ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_490c1158f7" +FOREIGN KEY ("containee_id") + REFERENCES "kithe_models" ("id") + +  (1.9ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_091010187b" +FOREIGN KEY ("container_id") + REFERENCES "kithe_models" ("id") + +  (3.0ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d" +FOREIGN KEY ("leaf_representative_id") + REFERENCES "kithe_models" ("id") + +  (1.9ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780" +FOREIGN KEY ("parent_id") + REFERENCES "kithe_models" ("id") + +  (1.7ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d" +FOREIGN KEY ("representative_id") + REFERENCES "kithe_models" ("id") + +  (2.9ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY) +  (0.9ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC +  (1.1ms) INSERT INTO "schema_migrations" (version) VALUES (20190404144551) +  (0.6ms) INSERT INTO "schema_migrations" (version) VALUES +(20181015143259), +(20181015143413), +(20181015143737), +(20181031190647), +(20181128185658), +(20190103144947), +(20190109192252); + + +  (3.3ms) 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) + 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]] +  (0.2ms) BEGIN + 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-06-04 16:49:37.613161"], ["updated_at", "2020-06-04 16:49:37.613161"]] +  (0.4ms) COMMIT + 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]] + 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]] +  (0.1ms) BEGIN + 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", "7ac4a20ed84fd4d14ae476bfa58fc376b3ce6739"], ["created_at", "2020-06-04 16:49:37.623813"], ["updated_at", "2020-06-04 16:49:37.623813"]] +  (0.3ms) COMMIT + SQL (15.0ms) CREATE EXTENSION IF NOT EXISTS "pgcrypto" + SQL (0.2ms) CREATE EXTENSION IF NOT EXISTS "plpgsql" +  (2.2ms) CREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint) + RETURNS text + LANGUAGE plpgsql +AS $function$ + DECLARE + new_id_int bigint; + new_id_str character varying := ''; + done bool; + tries integer; + alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']; + alphabet_length integer := array_length(alphabet, 1); + + BEGIN + done := false; + tries := 0; + WHILE (NOT done) LOOP + tries := tries + 1; + IF (tries > 3) THEN + RAISE 'Could not find non-conflicting friendlier_id in 3 tries'; + END IF; + + new_id_int := trunc(random() * (max_value - min_value) + min_value); + + -- convert bigint to a Base-36 alphanumeric string + -- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/ + -- https://gist.github.com/btbytes/7159902 + WHILE new_id_int != 0 LOOP + new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str; + new_id_int := new_id_int / alphabet_length; + END LOOP; + + done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str); + END LOOP; + RETURN new_id_str; + END; + $function$ + +  (0.2ms) DROP TABLE IF EXISTS "kithe_derivatives" CASCADE +  (31.4ms) 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) +  (4.3ms) CREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key") +  (1.1ms) CREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id") +  (0.2ms) DROP TABLE IF EXISTS "kithe_model_contains" CASCADE +  (2.4ms) CREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid) +  (1.8ms) CREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id") +  (1.7ms) CREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id") +  (3.8ms) DROP TABLE IF EXISTS "kithe_models" CASCADE +  (4.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, "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) +  (1.1ms) CREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id") +  (1.2ms) CREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id") +  (3.1ms) CREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id") +  (1.4ms) CREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id") +  (10.2ms) CREATE TABLE "plain_active_records" ("id" bigserial primary key, "title" character varying, "description" text) +  (4.9ms) ALTER TABLE "kithe_derivatives" ADD CONSTRAINT "fk_rails_3dac8b4201" +FOREIGN KEY ("asset_id") + REFERENCES "kithe_models" ("id") + +  (3.0ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_490c1158f7" +FOREIGN KEY ("containee_id") + REFERENCES "kithe_models" ("id") + +  (5.0ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_091010187b" +FOREIGN KEY ("container_id") + REFERENCES "kithe_models" ("id") + +  (14.1ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d" +FOREIGN KEY ("leaf_representative_id") + REFERENCES "kithe_models" ("id") + +  (6.8ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780" +FOREIGN KEY ("parent_id") + REFERENCES "kithe_models" ("id") + +  (8.0ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d" +FOREIGN KEY ("representative_id") + REFERENCES "kithe_models" ("id") + +  (14.5ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY) +  (0.6ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC +  (0.7ms) INSERT INTO "schema_migrations" (version) VALUES (20190404144551) +  (0.7ms) INSERT INTO "schema_migrations" (version) VALUES +(20181015143259), +(20181015143413), +(20181015143737), +(20181031190647), +(20181128185658), +(20190103144947), +(20190109192252); + + +  (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) + 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]] +  (0.2ms) BEGIN + 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-06-04 16:49:37.900916"], ["updated_at", "2020-06-04 16:49:37.900916"]] +  (0.6ms) COMMIT + 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]] +  (0.2ms) BEGIN + ActiveRecord::InternalMetadata Update (0.6ms) UPDATE "ar_internal_metadata" SET "value" = $1, "updated_at" = $2 WHERE "ar_internal_metadata"."key" = $3 [["value", "test"], ["updated_at", "2020-06-04 16:49:37.909774"], ["key", "environment"]] +  (0.7ms) COMMIT + ActiveRecord::InternalMetadata Load (0.6ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "schema_sha1"], ["LIMIT", 1]] +  (0.2ms) BEGIN + 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", "7ac4a20ed84fd4d14ae476bfa58fc376b3ce6739"], ["created_at", "2020-06-04 16:49:37.920363"], ["updated_at", "2020-06-04 16:49:37.920363"]] +  (0.4ms) COMMIT +  (1.4ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC +  (3.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC +  (22.8ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]] +  (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC +  (0.3ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]] +  (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC +  (0.4ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]] +  (364.2ms) DROP DATABASE IF EXISTS "kithe_test" +  (864.3ms) CREATE DATABASE "kithe_test" ENCODING = 'unicode' + SQL (64.0ms) CREATE EXTENSION IF NOT EXISTS "pgcrypto" + SQL (1.5ms) CREATE EXTENSION IF NOT EXISTS "plpgsql" +  (10.4ms) CREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint) + RETURNS text + LANGUAGE plpgsql +AS $function$ + DECLARE + new_id_int bigint; + new_id_str character varying := ''; + done bool; + tries integer; + alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', + 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']; + alphabet_length integer := array_length(alphabet, 1); + + BEGIN + done := false; + tries := 0; + WHILE (NOT done) LOOP + tries := tries + 1; + IF (tries > 3) THEN + RAISE 'Could not find non-conflicting friendlier_id in 3 tries'; + END IF; + + new_id_int := trunc(random() * (max_value - min_value) + min_value); + + -- convert bigint to a Base-36 alphanumeric string + -- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/ + -- https://gist.github.com/btbytes/7159902 + WHILE new_id_int != 0 LOOP + new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str; + new_id_int := new_id_int / alphabet_length; + END LOOP; + + done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str); + END LOOP; + RETURN new_id_str; + END; + $function$ + +  (0.5ms) DROP TABLE IF EXISTS "kithe_derivatives" CASCADE +  (34.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) +  (2.0ms) CREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key") +  (2.0ms) CREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id") +  (0.5ms) DROP TABLE IF EXISTS "kithe_model_contains" CASCADE +  (2.1ms) CREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid) +  (5.0ms) CREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id") +  (1.6ms) CREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id") +  (0.3ms) DROP TABLE IF EXISTS "kithe_models" CASCADE +  (29.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) +  (1.6ms) CREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id") +  (3.2ms) CREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id") +  (1.4ms) CREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id") +  (6.3ms) CREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id") +  (4.3ms) ALTER TABLE "kithe_derivatives" ADD CONSTRAINT "fk_rails_3dac8b4201" +FOREIGN KEY ("asset_id") + REFERENCES "kithe_models" ("id") + +  (3.4ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_490c1158f7" +FOREIGN KEY ("containee_id") + REFERENCES "kithe_models" ("id") + +  (3.0ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_091010187b" +FOREIGN KEY ("container_id") + REFERENCES "kithe_models" ("id") + +  (4.3ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d" +FOREIGN KEY ("leaf_representative_id") + REFERENCES "kithe_models" ("id") + +  (3.0ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780" +FOREIGN KEY ("parent_id") + REFERENCES "kithe_models" ("id") + +  (3.7ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d" +FOREIGN KEY ("representative_id") + REFERENCES "kithe_models" ("id") + +  (5.8ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY) +  (1.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC +  (8.9ms) INSERT INTO "schema_migrations" (version) VALUES (20190404144551) +  (11.8ms) INSERT INTO "schema_migrations" (version) VALUES +(20181015143259), +(20181015143413), +(20181015143737), +(20181031190647), +(20181128185658), +(20190103144947), +(20190109192252); + + +  (5.6ms) 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) + 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]] +  (0.4ms) BEGIN + ActiveRecord::InternalMetadata Create (0.9ms) 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-11-11 21:42:07.161354"], ["updated_at", "2020-11-11 21:42:07.161354"]] +  (0.4ms) COMMIT + 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]] +  (0.4ms) BEGIN + ActiveRecord::InternalMetadata Update (0.5ms) UPDATE "ar_internal_metadata" SET "value" = $1, "updated_at" = $2 WHERE "ar_internal_metadata"."key" = $3 [["value", "test"], ["updated_at", "2020-11-11 21:42:07.170009"], ["key", "environment"]] +  (0.5ms) COMMIT + ActiveRecord::InternalMetadata Load (1.1ms) SELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2 [["key", "schema_sha1"], ["LIMIT", 1]] +  (0.2ms) BEGIN + ActiveRecord::InternalMetadata Create (0.4ms) 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-11-11 21:42:07.182090"], ["updated_at", "2020-11-11 21:42:07.182090"]] +  (0.4ms) COMMIT