kithe 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ec505269282c50ba304c8b771adf73d277b9d2ceaa86bbeba671f8227d433009
4
- data.tar.gz: d341f483208b2842e492096babbd555a5c36fd93753224ff2b9f5f8a8fc11ecf
3
+ metadata.gz: e69743b96f34a0e3fcf7554d7c72e27dad32388a83db047911dba9ab8540e067
4
+ data.tar.gz: bf54b5bf9b74137ea06ca64dd67c18517423e85d8e83f785daca31919fb36111
5
5
  SHA512:
6
- metadata.gz: 79488731d167909bb237b06d797553dbbf5f7d358ceac4e33151091a7ba6ae57abbefe42ee1a1223a80c15be161ba5995a32bbcd532486b8edfa9f451af0c1a6
7
- data.tar.gz: 8eee6d4c73de8727e12005fd0da56efb6808019377fa769bd4e941d69eaa8461e339025e44768ba08d8e235492773b262da847410362a5f15b125172fff72fce
6
+ metadata.gz: f9e2d903df8e7021a1ae6ae1f24e4e8c67d06e918feb6ff56e636b79775c269ec347786b0ba29e589d64f4c8d05c09a1d3302b18f018834649e523d099c592cc
7
+ data.tar.gz: 7b705aac817804994c1617871306a5d3f539a79ac8814e31d21651e0673a69ec2feae6052c59affa5009f3e07d9b4db0dae461f70ca86bf8adbd05528f6a5353
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # Kithe
2
2
  An experiment in shareable tools/components for building a digital collections app in Rails.
3
3
 
4
- [![Build Status](https://travis-ci.org/sciencehistory/kithe.svg?branch=master)](https://travis-ci.org/sciencehistory/kithe)
5
- [![Gem Version](https://badge.fury.io/rb/kithe.svg)](https://badge.fury.io/rb/kithe)
4
+ [![Build Status](https://github.com/sciencehistory/kithe/workflows/CI/badge.svg?branch=master)](https://github.com/sciencehistory/kithe/actions?query=workflow%3ACI+branch%3Amaster) [![Gem Version](https://badge.fury.io/rb/kithe.svg)](https://badge.fury.io/rb/kithe)
6
5
 
7
6
  ## What is kithe?
8
7
 
@@ -61,7 +60,7 @@ So you want to start an app that uses kithe. We should later provide better 'get
61
60
 
62
61
  * Again re-iterate that kithe requires your Rails app use postgres, 9.5+.
63
62
 
64
- * kithe requires Rails 5.2 or 6.0.
63
+ * kithe works with Rails 5.2 through 6.1.
65
64
 
66
65
  * To install migrations from kithe to setup your database for it's models: `rake kithe_engine:install:migrations`
67
66
 
@@ -88,7 +87,8 @@ This is a Rails 'engine' whose template was created with: `rails plugin new kith
88
87
 
89
88
  * Note we are currently using the standard rails-generated dummy app in spec/dummy for testing, rather than [engine_cart](https://github.com/cbeer/engine_cart) or [combustion](https://github.com/pat/combustion).
90
89
  * Before you run the tests for the first time, create the database by running: `rails db:setup`. This will create two databases, kithe_development and kithe_test.
91
- * We do use [appraisal](https://github.com/thoughtbot/appraisal) to test under multiple rails versions,but still wtih the standard dummy app. It works for both Rails 5.2 and 6.0, because Rails structure changes have settled down.
90
+ * Some of the rspec tests depend on [FFmpeg](https://ffmpeg.org/) for testing file derivative transformations. Mac users can install [ffmpeg via homebrew](https://formulae.brew.sh/formula/ffmpeg): `brew install ffmpeg`
91
+ * We do use [appraisal](https://github.com/thoughtbot/appraisal) to test under multiple rails versions, but still with the standard dummy app. It works for both Rails 5.2 and 6.0, because Rails structure changes have settled down.
92
92
  * Locally you can run `bundle exec appraisal rspec` to run tests multiple times for each rails we have configured, or eg `bundle exec appraisal rails-60 rspec` for a particular one.
93
93
  * If the project `Gemfile` _or_ `Appraisal` file changes, you may need to re-run `bundle exec appraisal install` and commit changes.
94
94
 
@@ -44,7 +44,7 @@ module Kithe
44
44
  writer.put(context)
45
45
  end
46
46
  else
47
- writer.delete(record.id)
47
+ writer.delete(record.send(Kithe.indexable_settings.solr_id_value_attribute))
48
48
  end
49
49
  end
50
50
 
@@ -9,7 +9,7 @@ module Kithe
9
9
  #
10
10
  # You may also want to consider [railsconfig](https://github.com/railsconfig/config)
11
11
  #
12
- # Kithe::Config:
12
+ # Kithe::ConfigBase:
13
13
  #
14
14
  # * uses an explicit declared list of allowable config keys, no silent typos
15
15
  # * can read from a local YAML file or ENV, by default letting ENV override local YAML file values.
@@ -97,6 +97,11 @@ module Kithe
97
97
  # This doesn't use any locking for concurrent initial loads, which is technically not
98
98
  # great, but probably shouldn't be a problem in practice, especially in MRI. Trying to
99
99
  # do proper locking with lazy load was too hard for me right now.
100
+ #
101
+ # ## Auto-loading
102
+ #
103
+ # This is intentionally NOT in an auto-loaded directory, so it can be used more
104
+ # easily in Rails initialization without problems. https://github.com/rails/rails/issues/40904
100
105
  class ConfigBase
101
106
  include Singleton
102
107
 
@@ -11,6 +11,9 @@ require 'shrine'
11
11
  require 'fx'
12
12
  require 'kithe/patch_fx'
13
13
 
14
+ # not auto-loaded, let's just load it for backwards compat though
15
+ require "kithe/config_base"
16
+
14
17
  module Kithe
15
18
  class Engine < ::Rails::Engine
16
19
  config.generators do |g|
@@ -8,7 +8,7 @@ module Kithe
8
8
  @writer_class_name = writer_class_name
9
9
  @writer_settings = writer_settings
10
10
  @model_name_solr_field = model_name_solr_field
11
- @solr_id_value_attribute = solr_id_value_attribute
11
+ @solr_id_value_attribute = solr_id_value_attribute || 'id'
12
12
  end
13
13
 
14
14
  # Use configured solr_url, and merge together with configured
@@ -2,5 +2,5 @@ module Kithe
2
2
  # not sure why rubygems turned our alphas into 2.0.0.pre.alpha1, inserting
3
3
  # "pre". We need to do same thing with betas to get version orderings
4
4
  # appropriate.
5
- VERSION = '2.0.1'
5
+ VERSION = '2.0.2'
6
6
  end
@@ -0,0 +1,3 @@
1
+ # A Plain Old ActiveRecord (ha) for tests.
2
+ class PlainActiveRecord < ApplicationRecord
3
+ end
@@ -58,6 +58,12 @@ development:
58
58
  test:
59
59
  <<: *default
60
60
  database: kithe_test
61
+ # ENV POSTGRES_USER and POSTGRES_PASSWORD set in CI, usually empty
62
+ # in local tests, where pg is usually running with no authentication required
63
+ host: <%= ENV['POSTGRES_HOST'] %>
64
+ username: <%= ENV['POSTGRES_USER'] %>
65
+ password: <%= ENV['POSTGRES_PASSWORD'] %>
66
+
61
67
 
62
68
  # As with config/secrets.yml, you never want to store sensitive information,
63
69
  # like your database password, in your source code. If your source code is
@@ -111540,3 +111540,749 @@ FOREIGN KEY ("representative_id")
111540
111540
  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"]]
111541
111541
   (0.5ms) COMMIT
111542
111542
   (1.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
111543
+  (2.9ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
111544
+  (0.6ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
111545
+  (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
111546
+  (0.3ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
111547
+  (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
111548
+  (0.2ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
111549
+  (1.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
111550
+  (0.6ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
111551
+  (0.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
111552
+  (0.3ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
111553
+  (0.4ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
111554
+  (0.3ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
111555
+ SQL (38.3ms) CREATE EXTENSION IF NOT EXISTS "pgcrypto"
111556
+ SQL (0.3ms) CREATE EXTENSION IF NOT EXISTS "plpgsql"
111557
+  (32.7ms) CREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint)
111558
+ RETURNS text
111559
+ LANGUAGE plpgsql
111560
+ AS $function$
111561
+ DECLARE
111562
+ new_id_int bigint;
111563
+ new_id_str character varying := '';
111564
+ done bool;
111565
+ tries integer;
111566
+ alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
111567
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
111568
+ 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
111569
+ alphabet_length integer := array_length(alphabet, 1);
111570
+
111571
+ BEGIN
111572
+ done := false;
111573
+ tries := 0;
111574
+ WHILE (NOT done) LOOP
111575
+ tries := tries + 1;
111576
+ IF (tries > 3) THEN
111577
+ RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
111578
+ END IF;
111579
+
111580
+ new_id_int := trunc(random() * (max_value - min_value) + min_value);
111581
+
111582
+ -- convert bigint to a Base-36 alphanumeric string
111583
+ -- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
111584
+ -- https://gist.github.com/btbytes/7159902
111585
+ WHILE new_id_int != 0 LOOP
111586
+ new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
111587
+ new_id_int := new_id_int / alphabet_length;
111588
+ END LOOP;
111589
+
111590
+ done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
111591
+ END LOOP;
111592
+ RETURN new_id_str;
111593
+ END;
111594
+ $function$
111595
+ 
111596
+  (45.1ms) DROP TABLE IF EXISTS "kithe_derivatives" CASCADE
111597
+  (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)
111598
+  (1.8ms) CREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")
111599
+  (1.5ms) CREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")
111600
+  (3.6ms) DROP TABLE IF EXISTS "kithe_model_contains" CASCADE
111601
+  (4.5ms) CREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid)
111602
+  (2.0ms) CREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")
111603
+  (1.7ms) CREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")
111604
+  (7.3ms) DROP TABLE IF EXISTS "kithe_models" CASCADE
111605
+  (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)
111606
+  (1.3ms) CREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")
111607
+  (1.8ms) CREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")
111608
+  (1.3ms) CREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")
111609
+  (1.2ms) CREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")
111610
+  (8.9ms) CREATE TABLE "plain_old_ar" ("id" bigserial primary key, "title" character varying, "description" text)
111611
+  (6.3ms) ALTER TABLE "kithe_derivatives" ADD CONSTRAINT "fk_rails_3dac8b4201"
111612
+ FOREIGN KEY ("asset_id")
111613
+ REFERENCES "kithe_models" ("id")
111614
+ 
111615
+  (3.9ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_490c1158f7"
111616
+ FOREIGN KEY ("containee_id")
111617
+ REFERENCES "kithe_models" ("id")
111618
+ 
111619
+  (2.8ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_091010187b"
111620
+ FOREIGN KEY ("container_id")
111621
+ REFERENCES "kithe_models" ("id")
111622
+ 
111623
+  (1.8ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
111624
+ FOREIGN KEY ("leaf_representative_id")
111625
+ REFERENCES "kithe_models" ("id")
111626
+ 
111627
+  (3.4ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
111628
+ FOREIGN KEY ("parent_id")
111629
+ REFERENCES "kithe_models" ("id")
111630
+ 
111631
+  (1.9ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
111632
+ FOREIGN KEY ("representative_id")
111633
+ REFERENCES "kithe_models" ("id")
111634
+ 
111635
+  (0.8ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
111636
+ 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]]
111637
+ 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]]
111638
+ 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]]
111639
+  (0.2ms) BEGIN
111640
+ 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"]]
111641
+  (0.4ms) COMMIT
111642
+ SQL (2.6ms) CREATE EXTENSION IF NOT EXISTS "pgcrypto"
111643
+ SQL (0.5ms) CREATE EXTENSION IF NOT EXISTS "plpgsql"
111644
+  (28.9ms) CREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint)
111645
+ RETURNS text
111646
+ LANGUAGE plpgsql
111647
+ AS $function$
111648
+ DECLARE
111649
+ new_id_int bigint;
111650
+ new_id_str character varying := '';
111651
+ done bool;
111652
+ tries integer;
111653
+ alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
111654
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
111655
+ 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
111656
+ alphabet_length integer := array_length(alphabet, 1);
111657
+
111658
+ BEGIN
111659
+ done := false;
111660
+ tries := 0;
111661
+ WHILE (NOT done) LOOP
111662
+ tries := tries + 1;
111663
+ IF (tries > 3) THEN
111664
+ RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
111665
+ END IF;
111666
+
111667
+ new_id_int := trunc(random() * (max_value - min_value) + min_value);
111668
+
111669
+ -- convert bigint to a Base-36 alphanumeric string
111670
+ -- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
111671
+ -- https://gist.github.com/btbytes/7159902
111672
+ WHILE new_id_int != 0 LOOP
111673
+ new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
111674
+ new_id_int := new_id_int / alphabet_length;
111675
+ END LOOP;
111676
+
111677
+ done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
111678
+ END LOOP;
111679
+ RETURN new_id_str;
111680
+ END;
111681
+ $function$
111682
+ 
111683
+  (29.1ms) DROP TABLE IF EXISTS "kithe_derivatives" CASCADE
111684
+  (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)
111685
+  (2.2ms) CREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")
111686
+  (1.3ms) CREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")
111687
+  (2.7ms) DROP TABLE IF EXISTS "kithe_model_contains" CASCADE
111688
+  (1.3ms) CREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid)
111689
+  (1.3ms) CREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")
111690
+  (1.3ms) CREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")
111691
+  (6.6ms) DROP TABLE IF EXISTS "kithe_models" CASCADE
111692
+  (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)
111693
+  (1.5ms) CREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")
111694
+  (1.3ms) CREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")
111695
+  (1.3ms) CREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")
111696
+  (1.3ms) CREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")
111697
+  (4.5ms) CREATE TABLE "plain_old_ar" ("id" bigserial primary key, "title" character varying, "description" text)
111698
+  (6.6ms) ALTER TABLE "kithe_derivatives" ADD CONSTRAINT "fk_rails_3dac8b4201"
111699
+ FOREIGN KEY ("asset_id")
111700
+ REFERENCES "kithe_models" ("id")
111701
+ 
111702
+  (2.0ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_490c1158f7"
111703
+ FOREIGN KEY ("containee_id")
111704
+ REFERENCES "kithe_models" ("id")
111705
+ 
111706
+  (1.7ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_091010187b"
111707
+ FOREIGN KEY ("container_id")
111708
+ REFERENCES "kithe_models" ("id")
111709
+ 
111710
+  (1.8ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
111711
+ FOREIGN KEY ("leaf_representative_id")
111712
+ REFERENCES "kithe_models" ("id")
111713
+ 
111714
+  (1.7ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
111715
+ FOREIGN KEY ("parent_id")
111716
+ REFERENCES "kithe_models" ("id")
111717
+ 
111718
+  (1.8ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
111719
+ FOREIGN KEY ("representative_id")
111720
+ REFERENCES "kithe_models" ("id")
111721
+ 
111722
+  (1.1ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
111723
+ 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]]
111724
+  (0.2ms) BEGIN
111725
+ 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"]]
111726
+  (0.5ms) COMMIT
111727
+ 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]]
111728
+  (0.2ms) BEGIN
111729
+ 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"]]
111730
+  (0.4ms) COMMIT
111731
+ 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]]
111732
+  (0.2ms) BEGIN
111733
+ 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"]]
111734
+  (0.5ms) COMMIT
111735
+  (1.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
111736
+  (0.6ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
111737
+  (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
111738
+  (0.3ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
111739
+  (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
111740
+  (0.3ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
111741
+  (340.9ms) DROP DATABASE IF EXISTS "kithe_development"
111742
+  (224.9ms) DROP DATABASE IF EXISTS "kithe_test"
111743
+  (701.4ms) CREATE DATABASE "kithe_development" ENCODING = 'unicode'
111744
+  (483.4ms) CREATE DATABASE "kithe_test" ENCODING = 'unicode'
111745
+ SQL (182.5ms) CREATE EXTENSION IF NOT EXISTS "pgcrypto"
111746
+ SQL (0.2ms) CREATE EXTENSION IF NOT EXISTS "plpgsql"
111747
+  (2.2ms) CREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint)
111748
+ RETURNS text
111749
+ LANGUAGE plpgsql
111750
+ AS $function$
111751
+ DECLARE
111752
+ new_id_int bigint;
111753
+ new_id_str character varying := '';
111754
+ done bool;
111755
+ tries integer;
111756
+ alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
111757
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
111758
+ 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
111759
+ alphabet_length integer := array_length(alphabet, 1);
111760
+
111761
+ BEGIN
111762
+ done := false;
111763
+ tries := 0;
111764
+ WHILE (NOT done) LOOP
111765
+ tries := tries + 1;
111766
+ IF (tries > 3) THEN
111767
+ RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
111768
+ END IF;
111769
+
111770
+ new_id_int := trunc(random() * (max_value - min_value) + min_value);
111771
+
111772
+ -- convert bigint to a Base-36 alphanumeric string
111773
+ -- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
111774
+ -- https://gist.github.com/btbytes/7159902
111775
+ WHILE new_id_int != 0 LOOP
111776
+ new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
111777
+ new_id_int := new_id_int / alphabet_length;
111778
+ END LOOP;
111779
+
111780
+ done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
111781
+ END LOOP;
111782
+ RETURN new_id_str;
111783
+ END;
111784
+ $function$
111785
+ 
111786
+  (0.2ms) DROP TABLE IF EXISTS "kithe_derivatives" CASCADE
111787
+  (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)
111788
+  (2.6ms) CREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")
111789
+  (1.2ms) CREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")
111790
+  (0.2ms) DROP TABLE IF EXISTS "kithe_model_contains" CASCADE
111791
+  (1.7ms) CREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid)
111792
+  (1.2ms) CREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")
111793
+  (1.3ms) CREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")
111794
+  (0.3ms) DROP TABLE IF EXISTS "kithe_models" CASCADE
111795
+  (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)
111796
+  (1.3ms) CREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")
111797
+  (1.3ms) CREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")
111798
+  (1.5ms) CREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")
111799
+  (1.3ms) CREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")
111800
+  (8.7ms) CREATE TABLE "plain_old_ars" ("id" bigserial primary key, "title" character varying, "description" text)
111801
+  (3.4ms) ALTER TABLE "kithe_derivatives" ADD CONSTRAINT "fk_rails_3dac8b4201"
111802
+ FOREIGN KEY ("asset_id")
111803
+ REFERENCES "kithe_models" ("id")
111804
+ 
111805
+  (1.8ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_490c1158f7"
111806
+ FOREIGN KEY ("containee_id")
111807
+ REFERENCES "kithe_models" ("id")
111808
+ 
111809
+  (1.8ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_091010187b"
111810
+ FOREIGN KEY ("container_id")
111811
+ REFERENCES "kithe_models" ("id")
111812
+ 
111813
+  (1.8ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
111814
+ FOREIGN KEY ("leaf_representative_id")
111815
+ REFERENCES "kithe_models" ("id")
111816
+ 
111817
+  (1.7ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
111818
+ FOREIGN KEY ("parent_id")
111819
+ REFERENCES "kithe_models" ("id")
111820
+ 
111821
+  (1.7ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
111822
+ FOREIGN KEY ("representative_id")
111823
+ REFERENCES "kithe_models" ("id")
111824
+ 
111825
+  (3.8ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)
111826
+  (0.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
111827
+  (5.9ms) INSERT INTO "schema_migrations" (version) VALUES (20190404144551)
111828
+  (21.1ms) INSERT INTO "schema_migrations" (version) VALUES
111829
+ (20181015143259),
111830
+ (20181015143413),
111831
+ (20181015143737),
111832
+ (20181031190647),
111833
+ (20181128185658),
111834
+ (20190103144947),
111835
+ (20190109192252);
111836
+
111837
+ 
111838
+  (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)
111839
+ 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]]
111840
+  (0.7ms) BEGIN
111841
+ 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"]]
111842
+  (0.5ms) COMMIT
111843
+ 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]]
111844
+ 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]]
111845
+  (0.2ms) BEGIN
111846
+ 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"]]
111847
+  (0.4ms) COMMIT
111848
+ SQL (15.3ms) CREATE EXTENSION IF NOT EXISTS "pgcrypto"
111849
+ SQL (0.2ms) CREATE EXTENSION IF NOT EXISTS "plpgsql"
111850
+  (2.5ms) CREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint)
111851
+ RETURNS text
111852
+ LANGUAGE plpgsql
111853
+ AS $function$
111854
+ DECLARE
111855
+ new_id_int bigint;
111856
+ new_id_str character varying := '';
111857
+ done bool;
111858
+ tries integer;
111859
+ alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
111860
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
111861
+ 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
111862
+ alphabet_length integer := array_length(alphabet, 1);
111863
+
111864
+ BEGIN
111865
+ done := false;
111866
+ tries := 0;
111867
+ WHILE (NOT done) LOOP
111868
+ tries := tries + 1;
111869
+ IF (tries > 3) THEN
111870
+ RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
111871
+ END IF;
111872
+
111873
+ new_id_int := trunc(random() * (max_value - min_value) + min_value);
111874
+
111875
+ -- convert bigint to a Base-36 alphanumeric string
111876
+ -- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
111877
+ -- https://gist.github.com/btbytes/7159902
111878
+ WHILE new_id_int != 0 LOOP
111879
+ new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
111880
+ new_id_int := new_id_int / alphabet_length;
111881
+ END LOOP;
111882
+
111883
+ done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
111884
+ END LOOP;
111885
+ RETURN new_id_str;
111886
+ END;
111887
+ $function$
111888
+ 
111889
+  (0.2ms) DROP TABLE IF EXISTS "kithe_derivatives" CASCADE
111890
+  (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)
111891
+  (1.8ms) CREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")
111892
+  (1.2ms) CREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")
111893
+  (0.2ms) DROP TABLE IF EXISTS "kithe_model_contains" CASCADE
111894
+  (1.2ms) CREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid)
111895
+  (1.2ms) CREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")
111896
+  (1.2ms) CREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")
111897
+  (0.4ms) DROP TABLE IF EXISTS "kithe_models" CASCADE
111898
+  (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)
111899
+  (1.7ms) CREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")
111900
+  (1.3ms) CREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")
111901
+  (1.2ms) CREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")
111902
+  (1.1ms) CREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")
111903
+  (4.5ms) CREATE TABLE "plain_old_ars" ("id" bigserial primary key, "title" character varying, "description" text)
111904
+  (6.5ms) ALTER TABLE "kithe_derivatives" ADD CONSTRAINT "fk_rails_3dac8b4201"
111905
+ FOREIGN KEY ("asset_id")
111906
+ REFERENCES "kithe_models" ("id")
111907
+ 
111908
+  (2.1ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_490c1158f7"
111909
+ FOREIGN KEY ("containee_id")
111910
+ REFERENCES "kithe_models" ("id")
111911
+ 
111912
+  (1.7ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_091010187b"
111913
+ FOREIGN KEY ("container_id")
111914
+ REFERENCES "kithe_models" ("id")
111915
+ 
111916
+  (3.1ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
111917
+ FOREIGN KEY ("leaf_representative_id")
111918
+ REFERENCES "kithe_models" ("id")
111919
+ 
111920
+  (19.0ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
111921
+ FOREIGN KEY ("parent_id")
111922
+ REFERENCES "kithe_models" ("id")
111923
+ 
111924
+  (7.7ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
111925
+ FOREIGN KEY ("representative_id")
111926
+ REFERENCES "kithe_models" ("id")
111927
+ 
111928
+  (7.0ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)
111929
+  (0.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
111930
+  (0.8ms) INSERT INTO "schema_migrations" (version) VALUES (20190404144551)
111931
+  (0.6ms) INSERT INTO "schema_migrations" (version) VALUES
111932
+ (20181015143259),
111933
+ (20181015143413),
111934
+ (20181015143737),
111935
+ (20181031190647),
111936
+ (20181128185658),
111937
+ (20190103144947),
111938
+ (20190109192252);
111939
+
111940
+ 
111941
+  (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)
111942
+ 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]]
111943
+  (0.2ms) BEGIN
111944
+ 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"]]
111945
+  (0.4ms) COMMIT
111946
+ 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]]
111947
+  (0.1ms) BEGIN
111948
+ 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"]]
111949
+  (0.4ms) COMMIT
111950
+ 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]]
111951
+  (0.1ms) BEGIN
111952
+ 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"]]
111953
+  (0.4ms) COMMIT
111954
+  (0.9ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
111955
+ PlainOldAr Load (0.4ms) SELECT "plain_old_ars".* FROM "plain_old_ars" ORDER BY "plain_old_ars"."id" ASC LIMIT $1 [["LIMIT", 1]]
111956
+  (1.0ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
111957
+  (0.4ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
111958
+  (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
111959
+  (0.3ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
111960
+  (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
111961
+  (0.2ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
111962
+  (227.8ms) DROP DATABASE IF EXISTS "kithe_development"
111963
+  (217.1ms) DROP DATABASE IF EXISTS "kithe_test"
111964
+  (496.1ms) CREATE DATABASE "kithe_development" ENCODING = 'unicode'
111965
+  (495.5ms) CREATE DATABASE "kithe_test" ENCODING = 'unicode'
111966
+ SQL (25.2ms) CREATE EXTENSION IF NOT EXISTS "pgcrypto"
111967
+ SQL (0.3ms) CREATE EXTENSION IF NOT EXISTS "plpgsql"
111968
+  (23.8ms) CREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint)
111969
+ RETURNS text
111970
+ LANGUAGE plpgsql
111971
+ AS $function$
111972
+ DECLARE
111973
+ new_id_int bigint;
111974
+ new_id_str character varying := '';
111975
+ done bool;
111976
+ tries integer;
111977
+ alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
111978
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
111979
+ 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
111980
+ alphabet_length integer := array_length(alphabet, 1);
111981
+
111982
+ BEGIN
111983
+ done := false;
111984
+ tries := 0;
111985
+ WHILE (NOT done) LOOP
111986
+ tries := tries + 1;
111987
+ IF (tries > 3) THEN
111988
+ RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
111989
+ END IF;
111990
+
111991
+ new_id_int := trunc(random() * (max_value - min_value) + min_value);
111992
+
111993
+ -- convert bigint to a Base-36 alphanumeric string
111994
+ -- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
111995
+ -- https://gist.github.com/btbytes/7159902
111996
+ WHILE new_id_int != 0 LOOP
111997
+ new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
111998
+ new_id_int := new_id_int / alphabet_length;
111999
+ END LOOP;
112000
+
112001
+ done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
112002
+ END LOOP;
112003
+ RETURN new_id_str;
112004
+ END;
112005
+ $function$
112006
+ 
112007
+  (0.3ms) DROP TABLE IF EXISTS "kithe_derivatives" CASCADE
112008
+  (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)
112009
+  (2.1ms) CREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")
112010
+  (1.1ms) CREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")
112011
+  (0.2ms) DROP TABLE IF EXISTS "kithe_model_contains" CASCADE
112012
+  (1.1ms) CREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid)
112013
+  (1.4ms) CREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")
112014
+  (1.1ms) CREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")
112015
+  (0.2ms) DROP TABLE IF EXISTS "kithe_models" CASCADE
112016
+  (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)
112017
+  (1.2ms) CREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")
112018
+  (1.8ms) CREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")
112019
+  (6.3ms) CREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")
112020
+  (1.8ms) CREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")
112021
+  (3.6ms) CREATE TABLE "plain_active_records" ("id" bigserial primary key, "title" character varying, "description" text)
112022
+  (3.2ms) ALTER TABLE "kithe_derivatives" ADD CONSTRAINT "fk_rails_3dac8b4201"
112023
+ FOREIGN KEY ("asset_id")
112024
+ REFERENCES "kithe_models" ("id")
112025
+ 
112026
+  (136.8ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_490c1158f7"
112027
+ FOREIGN KEY ("containee_id")
112028
+ REFERENCES "kithe_models" ("id")
112029
+ 
112030
+  (1.9ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_091010187b"
112031
+ FOREIGN KEY ("container_id")
112032
+ REFERENCES "kithe_models" ("id")
112033
+ 
112034
+  (3.0ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
112035
+ FOREIGN KEY ("leaf_representative_id")
112036
+ REFERENCES "kithe_models" ("id")
112037
+ 
112038
+  (1.9ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
112039
+ FOREIGN KEY ("parent_id")
112040
+ REFERENCES "kithe_models" ("id")
112041
+ 
112042
+  (1.7ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
112043
+ FOREIGN KEY ("representative_id")
112044
+ REFERENCES "kithe_models" ("id")
112045
+ 
112046
+  (2.9ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)
112047
+  (0.9ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
112048
+  (1.1ms) INSERT INTO "schema_migrations" (version) VALUES (20190404144551)
112049
+  (0.6ms) INSERT INTO "schema_migrations" (version) VALUES
112050
+ (20181015143259),
112051
+ (20181015143413),
112052
+ (20181015143737),
112053
+ (20181031190647),
112054
+ (20181128185658),
112055
+ (20190103144947),
112056
+ (20190109192252);
112057
+
112058
+ 
112059
+  (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)
112060
+ 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]]
112061
+  (0.2ms) BEGIN
112062
+ 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"]]
112063
+  (0.4ms) COMMIT
112064
+ 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]]
112065
+ 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]]
112066
+  (0.1ms) BEGIN
112067
+ 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"]]
112068
+  (0.3ms) COMMIT
112069
+ SQL (15.0ms) CREATE EXTENSION IF NOT EXISTS "pgcrypto"
112070
+ SQL (0.2ms) CREATE EXTENSION IF NOT EXISTS "plpgsql"
112071
+  (2.2ms) CREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint)
112072
+ RETURNS text
112073
+ LANGUAGE plpgsql
112074
+ AS $function$
112075
+ DECLARE
112076
+ new_id_int bigint;
112077
+ new_id_str character varying := '';
112078
+ done bool;
112079
+ tries integer;
112080
+ alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
112081
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
112082
+ 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
112083
+ alphabet_length integer := array_length(alphabet, 1);
112084
+
112085
+ BEGIN
112086
+ done := false;
112087
+ tries := 0;
112088
+ WHILE (NOT done) LOOP
112089
+ tries := tries + 1;
112090
+ IF (tries > 3) THEN
112091
+ RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
112092
+ END IF;
112093
+
112094
+ new_id_int := trunc(random() * (max_value - min_value) + min_value);
112095
+
112096
+ -- convert bigint to a Base-36 alphanumeric string
112097
+ -- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
112098
+ -- https://gist.github.com/btbytes/7159902
112099
+ WHILE new_id_int != 0 LOOP
112100
+ new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
112101
+ new_id_int := new_id_int / alphabet_length;
112102
+ END LOOP;
112103
+
112104
+ done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
112105
+ END LOOP;
112106
+ RETURN new_id_str;
112107
+ END;
112108
+ $function$
112109
+ 
112110
+  (0.2ms) DROP TABLE IF EXISTS "kithe_derivatives" CASCADE
112111
+  (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)
112112
+  (4.3ms) CREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")
112113
+  (1.1ms) CREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")
112114
+  (0.2ms) DROP TABLE IF EXISTS "kithe_model_contains" CASCADE
112115
+  (2.4ms) CREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid)
112116
+  (1.8ms) CREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")
112117
+  (1.7ms) CREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")
112118
+  (3.8ms) DROP TABLE IF EXISTS "kithe_models" CASCADE
112119
+  (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)
112120
+  (1.1ms) CREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")
112121
+  (1.2ms) CREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")
112122
+  (3.1ms) CREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")
112123
+  (1.4ms) CREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")
112124
+  (10.2ms) CREATE TABLE "plain_active_records" ("id" bigserial primary key, "title" character varying, "description" text)
112125
+  (4.9ms) ALTER TABLE "kithe_derivatives" ADD CONSTRAINT "fk_rails_3dac8b4201"
112126
+ FOREIGN KEY ("asset_id")
112127
+ REFERENCES "kithe_models" ("id")
112128
+ 
112129
+  (3.0ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_490c1158f7"
112130
+ FOREIGN KEY ("containee_id")
112131
+ REFERENCES "kithe_models" ("id")
112132
+ 
112133
+  (5.0ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_091010187b"
112134
+ FOREIGN KEY ("container_id")
112135
+ REFERENCES "kithe_models" ("id")
112136
+ 
112137
+  (14.1ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
112138
+ FOREIGN KEY ("leaf_representative_id")
112139
+ REFERENCES "kithe_models" ("id")
112140
+ 
112141
+  (6.8ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
112142
+ FOREIGN KEY ("parent_id")
112143
+ REFERENCES "kithe_models" ("id")
112144
+ 
112145
+  (8.0ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
112146
+ FOREIGN KEY ("representative_id")
112147
+ REFERENCES "kithe_models" ("id")
112148
+ 
112149
+  (14.5ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)
112150
+  (0.6ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
112151
+  (0.7ms) INSERT INTO "schema_migrations" (version) VALUES (20190404144551)
112152
+  (0.7ms) INSERT INTO "schema_migrations" (version) VALUES
112153
+ (20181015143259),
112154
+ (20181015143413),
112155
+ (20181015143737),
112156
+ (20181031190647),
112157
+ (20181128185658),
112158
+ (20190103144947),
112159
+ (20190109192252);
112160
+
112161
+ 
112162
+  (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)
112163
+ 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]]
112164
+  (0.2ms) BEGIN
112165
+ 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"]]
112166
+  (0.6ms) COMMIT
112167
+ 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]]
112168
+  (0.2ms) BEGIN
112169
+ 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"]]
112170
+  (0.7ms) COMMIT
112171
+ 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]]
112172
+  (0.2ms) BEGIN
112173
+ 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"]]
112174
+  (0.4ms) COMMIT
112175
+  (1.4ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
112176
+  (3.5ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
112177
+  (22.8ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
112178
+  (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
112179
+  (0.3ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
112180
+  (0.3ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
112181
+  (0.4ms) SELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 [["key", "environment"]]
112182
+  (364.2ms) DROP DATABASE IF EXISTS "kithe_test"
112183
+  (864.3ms) CREATE DATABASE "kithe_test" ENCODING = 'unicode'
112184
+ SQL (64.0ms) CREATE EXTENSION IF NOT EXISTS "pgcrypto"
112185
+ SQL (1.5ms) CREATE EXTENSION IF NOT EXISTS "plpgsql"
112186
+  (10.4ms) CREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint)
112187
+ RETURNS text
112188
+ LANGUAGE plpgsql
112189
+ AS $function$
112190
+ DECLARE
112191
+ new_id_int bigint;
112192
+ new_id_str character varying := '';
112193
+ done bool;
112194
+ tries integer;
112195
+ alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
112196
+ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
112197
+ 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
112198
+ alphabet_length integer := array_length(alphabet, 1);
112199
+
112200
+ BEGIN
112201
+ done := false;
112202
+ tries := 0;
112203
+ WHILE (NOT done) LOOP
112204
+ tries := tries + 1;
112205
+ IF (tries > 3) THEN
112206
+ RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
112207
+ END IF;
112208
+
112209
+ new_id_int := trunc(random() * (max_value - min_value) + min_value);
112210
+
112211
+ -- convert bigint to a Base-36 alphanumeric string
112212
+ -- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
112213
+ -- https://gist.github.com/btbytes/7159902
112214
+ WHILE new_id_int != 0 LOOP
112215
+ new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
112216
+ new_id_int := new_id_int / alphabet_length;
112217
+ END LOOP;
112218
+
112219
+ done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
112220
+ END LOOP;
112221
+ RETURN new_id_str;
112222
+ END;
112223
+ $function$
112224
+ 
112225
+  (0.5ms) DROP TABLE IF EXISTS "kithe_derivatives" CASCADE
112226
+  (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)
112227
+  (2.0ms) CREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")
112228
+  (2.0ms) CREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")
112229
+  (0.5ms) DROP TABLE IF EXISTS "kithe_model_contains" CASCADE
112230
+  (2.1ms) CREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid)
112231
+  (5.0ms) CREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")
112232
+  (1.6ms) CREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")
112233
+  (0.3ms) DROP TABLE IF EXISTS "kithe_models" CASCADE
112234
+  (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)
112235
+  (1.6ms) CREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")
112236
+  (3.2ms) CREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")
112237
+  (1.4ms) CREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")
112238
+  (6.3ms) CREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")
112239
+  (4.3ms) ALTER TABLE "kithe_derivatives" ADD CONSTRAINT "fk_rails_3dac8b4201"
112240
+ FOREIGN KEY ("asset_id")
112241
+ REFERENCES "kithe_models" ("id")
112242
+ 
112243
+  (3.4ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_490c1158f7"
112244
+ FOREIGN KEY ("containee_id")
112245
+ REFERENCES "kithe_models" ("id")
112246
+ 
112247
+  (3.0ms) ALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_091010187b"
112248
+ FOREIGN KEY ("container_id")
112249
+ REFERENCES "kithe_models" ("id")
112250
+ 
112251
+  (4.3ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
112252
+ FOREIGN KEY ("leaf_representative_id")
112253
+ REFERENCES "kithe_models" ("id")
112254
+ 
112255
+  (3.0ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
112256
+ FOREIGN KEY ("parent_id")
112257
+ REFERENCES "kithe_models" ("id")
112258
+ 
112259
+  (3.7ms) ALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
112260
+ FOREIGN KEY ("representative_id")
112261
+ REFERENCES "kithe_models" ("id")
112262
+ 
112263
+  (5.8ms) CREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)
112264
+  (1.7ms) SELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC
112265
+  (8.9ms) INSERT INTO "schema_migrations" (version) VALUES (20190404144551)
112266
+  (11.8ms) INSERT INTO "schema_migrations" (version) VALUES
112267
+ (20181015143259),
112268
+ (20181015143413),
112269
+ (20181015143737),
112270
+ (20181031190647),
112271
+ (20181128185658),
112272
+ (20190103144947),
112273
+ (20190109192252);
112274
+
112275
+ 
112276
+  (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)
112277
+ 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]]
112278
+  (0.4ms) BEGIN
112279
+ 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"]]
112280
+  (0.4ms) COMMIT
112281
+ 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]]
112282
+  (0.4ms) BEGIN
112283
+ 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"]]
112284
+  (0.5ms) COMMIT
112285
+ 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]]
112286
+  (0.2ms) BEGIN
112287
+ 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"]]
112288
+  (0.4ms) COMMIT