kithe 2.0.0.pre.beta1 → 2.0.0.pre.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/kithe/engine.rb +11 -3
- data/lib/kithe/patch_fx.rb +39 -0
- data/lib/kithe/version.rb +1 -1
- data/spec/dummy/db/schema.rb +102 -0
- data/spec/dummy/log/development.log +2003 -0
- data/spec/dummy/log/test.log +3366 -0
- metadata +26 -6
- data/spec/dummy/db/structure.sql +0 -309
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d13f653a81cc8db86b8dfb6539c9d2fc1148996467c3298ff60b6c89babb37a5
|
4
|
+
data.tar.gz: 937fec71314c5449f3c0c6a541089a21edad1113bccc29425e449f86d68c3347
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51e979ddd89d045300ecb1306403f9a42b096d3689321806c2d4101256c46f95340e02b03b97f8fd50233d25e59d60723dc31e21d7349fcc771b0b7476f6e666
|
7
|
+
data.tar.gz: 89126c403d797e24d9679a4206c4c09dab0f76d0642f01511bb7f07c501a27ee6d43da7c5e50c15b06bba47f3ec53b53657ee713c06d57f7ad28f2beee5ce8d0
|
data/lib/kithe/engine.rb
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
require 'shrine'
|
2
2
|
|
3
|
+
# Gem "F(x)" or `fx` gem will get schema.rb to include locally-defined custom postgres functions
|
4
|
+
# and triggers, like we use. So apps can keep using schema.rb instead of structure.sql,
|
5
|
+
# and still have our custom functions preserved. We need to require it explicitly
|
6
|
+
# since it'll be an indirect dependency of the end app.
|
7
|
+
#
|
8
|
+
# But we need to patch it to create functions first so we can use them as default values
|
9
|
+
# https://github.com/teoljungberg/fx/issues/33
|
10
|
+
# https://github.com/teoljungberg/fx/pull/53
|
11
|
+
require 'fx'
|
12
|
+
require 'kithe/patch_fx'
|
13
|
+
|
3
14
|
module Kithe
|
4
15
|
class Engine < ::Rails::Engine
|
5
16
|
config.generators do |g|
|
@@ -8,8 +19,5 @@ module Kithe
|
|
8
19
|
g.assets false
|
9
20
|
g.helper false
|
10
21
|
end
|
11
|
-
|
12
|
-
# should only affect kithe development
|
13
|
-
config.active_record.schema_format = :sql
|
14
22
|
end
|
15
23
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# fx is a gem that lets Rails schema.rb capture postgres functions and triggers
|
2
|
+
#
|
3
|
+
# For it to work for our use case, we need it to define functions BEFORE tables when
|
4
|
+
# doing a `rake db:schema:load`, so we can refer to functions as default values in our
|
5
|
+
# tables.
|
6
|
+
#
|
7
|
+
# This is a known issue in fx, with a PR, but isn't yet merged/released, so we hack
|
8
|
+
# in a patch to force it. Better than forking.
|
9
|
+
#
|
10
|
+
# Based on: https://github.com/teoljungberg/fx/pull/53/
|
11
|
+
#
|
12
|
+
# We try to write future-compat code assuming that will be merged eventually....
|
13
|
+
|
14
|
+
require 'fx'
|
15
|
+
|
16
|
+
if Fx.configuration.respond_to?(:dump_functions_at_beginning_of_schema)
|
17
|
+
# we have the feature!
|
18
|
+
|
19
|
+
Fx.configure do |config|
|
20
|
+
config.dump_functions_at_beginning_of_schema = true
|
21
|
+
end
|
22
|
+
|
23
|
+
else
|
24
|
+
# Fx does not have the feature, we have to patch it in
|
25
|
+
|
26
|
+
require 'fx/schema_dumper/function'
|
27
|
+
|
28
|
+
module Fx
|
29
|
+
module SchemaDumper
|
30
|
+
module Function
|
31
|
+
def tables(stream)
|
32
|
+
functions(stream)
|
33
|
+
super
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
data/lib/kithe/version.rb
CHANGED
@@ -0,0 +1,102 @@
|
|
1
|
+
# This file is auto-generated from the current state of the database. Instead
|
2
|
+
# of editing this file, please use the migrations feature of Active Record to
|
3
|
+
# incrementally modify your database, and then regenerate this schema definition.
|
4
|
+
#
|
5
|
+
# This file is the source Rails uses to define your schema when running `rails
|
6
|
+
# db:schema:load`. When creating a new database, `rails db:schema:load` tends to
|
7
|
+
# be faster and is potentially less error prone than running all of your
|
8
|
+
# migrations from scratch. Old migrations may fail to apply correctly if those
|
9
|
+
# migrations use external dependencies or application code.
|
10
|
+
#
|
11
|
+
# It's strongly recommended that you check this file into your version control system.
|
12
|
+
|
13
|
+
ActiveRecord::Schema.define(version: 2019_04_04_144551) do
|
14
|
+
|
15
|
+
# These are extensions that must be enabled in order to support this database
|
16
|
+
enable_extension "pgcrypto"
|
17
|
+
enable_extension "plpgsql"
|
18
|
+
|
19
|
+
|
20
|
+
create_function :kithe_models_friendlier_id_gen, sql_definition: <<-SQL
|
21
|
+
CREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint)
|
22
|
+
RETURNS text
|
23
|
+
LANGUAGE plpgsql
|
24
|
+
AS $function$
|
25
|
+
DECLARE
|
26
|
+
new_id_int bigint;
|
27
|
+
new_id_str character varying := '';
|
28
|
+
done bool;
|
29
|
+
tries integer;
|
30
|
+
alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
|
31
|
+
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
32
|
+
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
|
33
|
+
alphabet_length integer := array_length(alphabet, 1);
|
34
|
+
|
35
|
+
BEGIN
|
36
|
+
done := false;
|
37
|
+
tries := 0;
|
38
|
+
WHILE (NOT done) LOOP
|
39
|
+
tries := tries + 1;
|
40
|
+
IF (tries > 3) THEN
|
41
|
+
RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
|
42
|
+
END IF;
|
43
|
+
|
44
|
+
new_id_int := trunc(random() * (max_value - min_value) + min_value);
|
45
|
+
|
46
|
+
-- convert bigint to a Base-36 alphanumeric string
|
47
|
+
-- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
|
48
|
+
-- https://gist.github.com/btbytes/7159902
|
49
|
+
WHILE new_id_int != 0 LOOP
|
50
|
+
new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
|
51
|
+
new_id_int := new_id_int / alphabet_length;
|
52
|
+
END LOOP;
|
53
|
+
|
54
|
+
done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
|
55
|
+
END LOOP;
|
56
|
+
RETURN new_id_str;
|
57
|
+
END;
|
58
|
+
$function$
|
59
|
+
SQL
|
60
|
+
create_table "kithe_derivatives", force: :cascade do |t|
|
61
|
+
t.string "key", null: false
|
62
|
+
t.jsonb "file_data"
|
63
|
+
t.uuid "asset_id", null: false
|
64
|
+
t.datetime "created_at", null: false
|
65
|
+
t.datetime "updated_at", null: false
|
66
|
+
t.index ["asset_id", "key"], name: "index_kithe_derivatives_on_asset_id_and_key", unique: true
|
67
|
+
t.index ["asset_id"], name: "index_kithe_derivatives_on_asset_id"
|
68
|
+
end
|
69
|
+
|
70
|
+
create_table "kithe_model_contains", id: false, force: :cascade do |t|
|
71
|
+
t.uuid "containee_id"
|
72
|
+
t.uuid "container_id"
|
73
|
+
t.index ["containee_id"], name: "index_kithe_model_contains_on_containee_id"
|
74
|
+
t.index ["container_id"], name: "index_kithe_model_contains_on_container_id"
|
75
|
+
end
|
76
|
+
|
77
|
+
create_table "kithe_models", id: :uuid, default: -> { "gen_random_uuid()" }, force: :cascade do |t|
|
78
|
+
t.string "title", null: false
|
79
|
+
t.string "type", null: false
|
80
|
+
t.integer "position"
|
81
|
+
t.jsonb "json_attributes"
|
82
|
+
t.datetime "created_at", null: false
|
83
|
+
t.datetime "updated_at", null: false
|
84
|
+
t.uuid "parent_id"
|
85
|
+
t.string "friendlier_id", default: -> { "kithe_models_friendlier_id_gen('2821109907456'::bigint, '101559956668415'::bigint)" }, null: false
|
86
|
+
t.jsonb "file_data"
|
87
|
+
t.uuid "representative_id"
|
88
|
+
t.uuid "leaf_representative_id"
|
89
|
+
t.integer "kithe_model_type", null: false
|
90
|
+
t.index ["friendlier_id"], name: "index_kithe_models_on_friendlier_id", unique: true
|
91
|
+
t.index ["leaf_representative_id"], name: "index_kithe_models_on_leaf_representative_id"
|
92
|
+
t.index ["parent_id"], name: "index_kithe_models_on_parent_id"
|
93
|
+
t.index ["representative_id"], name: "index_kithe_models_on_representative_id"
|
94
|
+
end
|
95
|
+
|
96
|
+
add_foreign_key "kithe_derivatives", "kithe_models", column: "asset_id"
|
97
|
+
add_foreign_key "kithe_model_contains", "kithe_models", column: "containee_id"
|
98
|
+
add_foreign_key "kithe_model_contains", "kithe_models", column: "container_id"
|
99
|
+
add_foreign_key "kithe_models", "kithe_models", column: "leaf_representative_id"
|
100
|
+
add_foreign_key "kithe_models", "kithe_models", column: "parent_id"
|
101
|
+
add_foreign_key "kithe_models", "kithe_models", column: "representative_id"
|
102
|
+
end
|
@@ -109537,3 +109537,2006 @@ FOREIGN KEY ("representative_id")
|
|
109537
109537
|
[1m[35m (0.1ms)[0m [1m[35mBEGIN[0m
|
109538
109538
|
[1m[36mActiveRecord::InternalMetadata Create (0.3ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"[0m [["key", "schema_sha1"], ["value", "0e24e2caa948e64f3be11233d707b8abffa0f356"], ["created_at", "2020-05-20 21:22:55.854305"], ["updated_at", "2020-05-20 21:22:55.854305"]]
|
109539
109539
|
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
109540
|
+
[1m[35m (4.1ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
109541
|
+
[1m[35m (6.2ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
109542
|
+
[1m[35m (0.4ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
109543
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
109544
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
109545
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
109546
|
+
[1m[35m (415.7ms)[0m [1m[35mDROP DATABASE IF EXISTS "kithe_development"[0m
|
109547
|
+
[1m[35m (199.9ms)[0m [1m[35mDROP DATABASE IF EXISTS "kithe_test"[0m
|
109548
|
+
[1m[35m (849.8ms)[0m [1m[35mCREATE DATABASE "kithe_development" ENCODING = 'unicode'[0m
|
109549
|
+
[1m[35m (615.6ms)[0m [1m[35mCREATE DATABASE "kithe_test" ENCODING = 'unicode'[0m
|
109550
|
+
[1m[35m (27.8ms)[0m [1m[35mCREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)[0m
|
109551
|
+
[1m[35m (5.0ms)[0m [1m[35mCREATE 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)[0m
|
109552
|
+
[1m[35m (11.6ms)[0m [1m[34mSELECT pg_try_advisory_lock(1601470156486188030)[0m
|
109553
|
+
[1m[35m (0.7ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
109554
|
+
Migrating to EnablePgcryptoExtension (20181015143259)
|
109555
|
+
[1m[35m (0.6ms)[0m [1m[35mBEGIN[0m
|
109556
|
+
[1m[35mSQL (188.1ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "pgcrypto"[0m
|
109557
|
+
[1m[36mprimary::SchemaMigration Create (4.2ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181015143259"]]
|
109558
|
+
[1m[35m (24.5ms)[0m [1m[35mCOMMIT[0m
|
109559
|
+
Migrating to CreateKitheModels (20181015143413)
|
109560
|
+
[1m[35m (0.8ms)[0m [1m[35mBEGIN[0m
|
109561
|
+
[1m[35m (24.7ms)[0m [1m[35mCREATE 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)[0m
|
109562
|
+
[1m[35m (0.5ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "parent_id" uuid[0m
|
109563
|
+
[1m[35m (8.0ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")[0m
|
109564
|
+
[1m[35m (17.7ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
|
109565
|
+
FOREIGN KEY ("parent_id")
|
109566
|
+
REFERENCES "kithe_models" ("id")
|
109567
|
+
[0m
|
109568
|
+
[1m[36mprimary::SchemaMigration Create (0.3ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181015143413"]]
|
109569
|
+
[1m[35m (0.5ms)[0m [1m[35mCOMMIT[0m
|
109570
|
+
Migrating to KitheModelsFriendlierId (20181015143737)
|
109571
|
+
[1m[35m (0.3ms)[0m [1m[35mBEGIN[0m
|
109572
|
+
[1m[35m (42.9ms)[0m [1m[35mCREATE OR REPLACE FUNCTION kithe_models_friendlier_id_gen(min_value bigint, max_value bigint) RETURNS text AS $$
|
109573
|
+
DECLARE
|
109574
|
+
new_id_int bigint;
|
109575
|
+
new_id_str character varying := '';
|
109576
|
+
done bool;
|
109577
|
+
tries integer;
|
109578
|
+
alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
|
109579
|
+
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
109580
|
+
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
|
109581
|
+
alphabet_length integer := array_length(alphabet, 1);
|
109582
|
+
|
109583
|
+
BEGIN
|
109584
|
+
done := false;
|
109585
|
+
tries := 0;
|
109586
|
+
WHILE (NOT done) LOOP
|
109587
|
+
tries := tries + 1;
|
109588
|
+
IF (tries > 3) THEN
|
109589
|
+
RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
|
109590
|
+
END IF;
|
109591
|
+
|
109592
|
+
new_id_int := trunc(random() * (max_value - min_value) + min_value);
|
109593
|
+
|
109594
|
+
-- convert bigint to a Base-36 alphanumeric string
|
109595
|
+
-- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
|
109596
|
+
-- https://gist.github.com/btbytes/7159902
|
109597
|
+
WHILE new_id_int != 0 LOOP
|
109598
|
+
new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
|
109599
|
+
new_id_int := new_id_int / alphabet_length;
|
109600
|
+
END LOOP;
|
109601
|
+
|
109602
|
+
done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
|
109603
|
+
END LOOP;
|
109604
|
+
RETURN new_id_str;
|
109605
|
+
END;
|
109606
|
+
$$ LANGUAGE plpgsql;
|
109607
|
+
[0m
|
109608
|
+
[1m[35m (43.1ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "friendlier_id" character varying DEFAULT kithe_models_friendlier_id_gen(2821109907456, 101559956668415) NOT NULL[0m
|
109609
|
+
[1m[35m (14.4ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")[0m
|
109610
|
+
[1m[36mprimary::SchemaMigration Create (0.5ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181015143737"]]
|
109611
|
+
[1m[35m (30.0ms)[0m [1m[35mCOMMIT[0m
|
109612
|
+
Migrating to AddFileDataToModel (20181031190647)
|
109613
|
+
[1m[35m (0.3ms)[0m [1m[35mBEGIN[0m
|
109614
|
+
[1m[35m (0.7ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "file_data" jsonb[0m
|
109615
|
+
[1m[36mprimary::SchemaMigration Create (1.0ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181031190647"]]
|
109616
|
+
[1m[35m (12.2ms)[0m [1m[35mCOMMIT[0m
|
109617
|
+
Migrating to CreateKitheDerivatives (20181128185658)
|
109618
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
109619
|
+
[1m[35m (91.1ms)[0m [1m[35mCREATE TABLE "kithe_derivatives" ("id" bigserial primary key, "key" character varying NOT NULL, "file_data" jsonb, "asset_id" uuid NOT NULL, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL, CONSTRAINT "fk_rails_3dac8b4201"
|
109620
|
+
FOREIGN KEY ("asset_id")
|
109621
|
+
REFERENCES "kithe_models" ("id")
|
109622
|
+
)[0m
|
109623
|
+
[1m[35m (1.4ms)[0m [1m[35mCREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")[0m
|
109624
|
+
[1m[35m (1.3ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")[0m
|
109625
|
+
[1m[36mprimary::SchemaMigration Create (0.4ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181128185658"]]
|
109626
|
+
[1m[35m (2.1ms)[0m [1m[35mCOMMIT[0m
|
109627
|
+
Migrating to AddRepresentativeRelations (20190103144947)
|
109628
|
+
[1m[35m (12.0ms)[0m [1m[35mBEGIN[0m
|
109629
|
+
[1m[35m (1.3ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "representative_id" uuid[0m
|
109630
|
+
[1m[35m (7.7ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")[0m
|
109631
|
+
[1m[35m (96.0ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
|
109632
|
+
FOREIGN KEY ("representative_id")
|
109633
|
+
REFERENCES "kithe_models" ("id")
|
109634
|
+
[0m
|
109635
|
+
[1m[35m (0.9ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "leaf_representative_id" uuid[0m
|
109636
|
+
[1m[35m (1.5ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")[0m
|
109637
|
+
[1m[35m (3.0ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
|
109638
|
+
FOREIGN KEY ("leaf_representative_id")
|
109639
|
+
REFERENCES "kithe_models" ("id")
|
109640
|
+
[0m
|
109641
|
+
[1m[36mprimary::SchemaMigration Create (0.5ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20190103144947"]]
|
109642
|
+
[1m[35m (6.3ms)[0m [1m[35mCOMMIT[0m
|
109643
|
+
Migrating to ContainsAssociation (20190109192252)
|
109644
|
+
[1m[35m (0.3ms)[0m [1m[35mBEGIN[0m
|
109645
|
+
[1m[35m (7.3ms)[0m [1m[35mCREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid, CONSTRAINT "fk_rails_490c1158f7"
|
109646
|
+
FOREIGN KEY ("containee_id")
|
109647
|
+
REFERENCES "kithe_models" ("id")
|
109648
|
+
, CONSTRAINT "fk_rails_091010187b"
|
109649
|
+
FOREIGN KEY ("container_id")
|
109650
|
+
REFERENCES "kithe_models" ("id")
|
109651
|
+
)[0m
|
109652
|
+
[1m[35m (13.6ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")[0m
|
109653
|
+
[1m[35m (1.4ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")[0m
|
109654
|
+
[1m[36mprimary::SchemaMigration Create (0.4ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20190109192252"]]
|
109655
|
+
[1m[35m (6.4ms)[0m [1m[35mCOMMIT[0m
|
109656
|
+
Migrating to KitheModelType (20190404144551)
|
109657
|
+
[1m[35m (0.3ms)[0m [1m[35mBEGIN[0m
|
109658
|
+
[1m[35m (0.4ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "kithe_model_type" integer[0m
|
109659
|
+
[1m[35m (0.5ms)[0m [1m[34mSELECT "kithe_models"."id" FROM "kithe_models" ORDER BY "kithe_models"."id" ASC LIMIT $1[0m [["LIMIT", 1000]]
|
109660
|
+
[1m[35m (0.6ms)[0m [1m[35mALTER TABLE "kithe_models" ALTER COLUMN "kithe_model_type" TYPE integer, ALTER COLUMN "kithe_model_type" SET NOT NULL[0m
|
109661
|
+
[1m[36mprimary::SchemaMigration Create (0.4ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20190404144551"]]
|
109662
|
+
[1m[35m (0.5ms)[0m [1m[35mCOMMIT[0m
|
109663
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.5ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
109664
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
109665
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.8ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"[0m [["key", "environment"], ["value", "development"], ["created_at", "2020-05-27 15:56:52.813959"], ["updated_at", "2020-05-27 15:56:52.813959"]]
|
109666
|
+
[1m[35m (6.0ms)[0m [1m[35mCOMMIT[0m
|
109667
|
+
[1m[35m (0.7ms)[0m [1m[34mSELECT pg_advisory_unlock(1601470156486188030)[0m
|
109668
|
+
[1m[35m (1.0ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
109669
|
+
[1m[35m (4.7ms)[0m [1m[34m SELECT
|
109670
|
+
pp.proname AS name,
|
109671
|
+
pg_get_functiondef(pp.oid) AS definition
|
109672
|
+
FROM pg_proc pp
|
109673
|
+
JOIN pg_namespace pn
|
109674
|
+
ON pn.oid = pp.pronamespace
|
109675
|
+
LEFT JOIN pg_depend pd
|
109676
|
+
ON pd.objid = pp.oid AND pd.deptype = 'e'
|
109677
|
+
WHERE pn.nspname = 'public' AND pd.objid IS NULL
|
109678
|
+
ORDER BY pp.oid;
|
109679
|
+
[0m
|
109680
|
+
[1m[35m (1.5ms)[0m [1m[34m SELECT
|
109681
|
+
pt.tgname AS name,
|
109682
|
+
pg_get_triggerdef(pt.oid) AS definition
|
109683
|
+
FROM pg_trigger pt
|
109684
|
+
JOIN pg_class pc
|
109685
|
+
ON (pc.oid = pt.tgrelid)
|
109686
|
+
JOIN pg_proc pp
|
109687
|
+
ON (pp.oid = pt.tgfoid)
|
109688
|
+
WHERE pt.tgname
|
109689
|
+
NOT ILIKE '%constraint%' AND pt.tgname NOT ILIKE 'pg%'
|
109690
|
+
ORDER BY pc.oid;
|
109691
|
+
[0m
|
109692
|
+
[1m[35m (1.2ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
109693
|
+
[1m[35m (0.5ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
109694
|
+
[1m[35m (0.4ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
109695
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
109696
|
+
[1m[35m (0.7ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
109697
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
109698
|
+
[1m[35m (209.2ms)[0m [1m[35mDROP DATABASE IF EXISTS "kithe_development"[0m
|
109699
|
+
[1m[35m (238.3ms)[0m [1m[35mDROP DATABASE IF EXISTS "kithe_test"[0m
|
109700
|
+
[1m[35m (743.0ms)[0m [1m[35mCREATE DATABASE "kithe_development" ENCODING = 'unicode'[0m
|
109701
|
+
[1m[35m (452.5ms)[0m [1m[35mCREATE DATABASE "kithe_test" ENCODING = 'unicode'[0m
|
109702
|
+
[1m[35mSQL (22.5ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "pgcrypto"[0m
|
109703
|
+
[1m[35mSQL (0.3ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "plpgsql"[0m
|
109704
|
+
[1m[35m (0.3ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_derivatives" CASCADE[0m
|
109705
|
+
[1m[35m (76.0ms)[0m [1m[35mCREATE 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)[0m
|
109706
|
+
[1m[35m (1.9ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")[0m
|
109707
|
+
[1m[35m (1.1ms)[0m [1m[35mCREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")[0m
|
109708
|
+
[1m[35m (0.2ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_model_contains" CASCADE[0m
|
109709
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid)[0m
|
109710
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")[0m
|
109711
|
+
[1m[35m (1.3ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")[0m
|
109712
|
+
[1m[35m (0.2ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_models" CASCADE[0m
|
109713
|
+
[1m[35m (3.5ms)[0m [1m[35mCREATE 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)[0m
|
109714
|
+
[1m[35m (222.1ms)[0m [1m[35mDROP DATABASE IF EXISTS "kithe_development"[0m
|
109715
|
+
[1m[35m (216.1ms)[0m [1m[35mDROP DATABASE IF EXISTS "kithe_test"[0m
|
109716
|
+
[1m[35m (1076.2ms)[0m [1m[35mCREATE DATABASE "kithe_development" ENCODING = 'unicode'[0m
|
109717
|
+
[1m[35m (619.8ms)[0m [1m[35mCREATE DATABASE "kithe_test" ENCODING = 'unicode'[0m
|
109718
|
+
[1m[35m (6.6ms)[0m [1m[35mCREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)[0m
|
109719
|
+
[1m[35m (27.0ms)[0m [1m[35mCREATE 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)[0m
|
109720
|
+
[1m[35m (0.4ms)[0m [1m[34mSELECT pg_try_advisory_lock(1601470156486188030)[0m
|
109721
|
+
[1m[35m (0.7ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
109722
|
+
Migrating to EnablePgcryptoExtension (20181015143259)
|
109723
|
+
[1m[35m (0.4ms)[0m [1m[35mBEGIN[0m
|
109724
|
+
[1m[35mSQL (28.3ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "pgcrypto"[0m
|
109725
|
+
[1m[36mprimary::SchemaMigration Create (0.6ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181015143259"]]
|
109726
|
+
[1m[35m (5.5ms)[0m [1m[35mCOMMIT[0m
|
109727
|
+
Migrating to CreateKitheModels (20181015143413)
|
109728
|
+
[1m[35m (0.3ms)[0m [1m[35mBEGIN[0m
|
109729
|
+
[1m[35m (17.4ms)[0m [1m[35mCREATE 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)[0m
|
109730
|
+
[1m[35m (0.5ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "parent_id" uuid[0m
|
109731
|
+
[1m[35m (7.0ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")[0m
|
109732
|
+
[1m[35m (3.6ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
|
109733
|
+
FOREIGN KEY ("parent_id")
|
109734
|
+
REFERENCES "kithe_models" ("id")
|
109735
|
+
[0m
|
109736
|
+
[1m[36mprimary::SchemaMigration Create (2.0ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181015143413"]]
|
109737
|
+
[1m[35m (1.9ms)[0m [1m[35mCOMMIT[0m
|
109738
|
+
Migrating to KitheModelsFriendlierId (20181015143737)
|
109739
|
+
[1m[35m (0.3ms)[0m [1m[35mBEGIN[0m
|
109740
|
+
[1m[35m (4.5ms)[0m [1m[35mCREATE OR REPLACE FUNCTION kithe_models_friendlier_id_gen(min_value bigint, max_value bigint) RETURNS text AS $$
|
109741
|
+
DECLARE
|
109742
|
+
new_id_int bigint;
|
109743
|
+
new_id_str character varying := '';
|
109744
|
+
done bool;
|
109745
|
+
tries integer;
|
109746
|
+
alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
|
109747
|
+
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
109748
|
+
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
|
109749
|
+
alphabet_length integer := array_length(alphabet, 1);
|
109750
|
+
|
109751
|
+
BEGIN
|
109752
|
+
done := false;
|
109753
|
+
tries := 0;
|
109754
|
+
WHILE (NOT done) LOOP
|
109755
|
+
tries := tries + 1;
|
109756
|
+
IF (tries > 3) THEN
|
109757
|
+
RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
|
109758
|
+
END IF;
|
109759
|
+
|
109760
|
+
new_id_int := trunc(random() * (max_value - min_value) + min_value);
|
109761
|
+
|
109762
|
+
-- convert bigint to a Base-36 alphanumeric string
|
109763
|
+
-- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
|
109764
|
+
-- https://gist.github.com/btbytes/7159902
|
109765
|
+
WHILE new_id_int != 0 LOOP
|
109766
|
+
new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
|
109767
|
+
new_id_int := new_id_int / alphabet_length;
|
109768
|
+
END LOOP;
|
109769
|
+
|
109770
|
+
done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
|
109771
|
+
END LOOP;
|
109772
|
+
RETURN new_id_str;
|
109773
|
+
END;
|
109774
|
+
$$ LANGUAGE plpgsql;
|
109775
|
+
[0m
|
109776
|
+
[1m[35m (41.5ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "friendlier_id" character varying DEFAULT kithe_models_friendlier_id_gen(2821109907456, 101559956668415) NOT NULL[0m
|
109777
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")[0m
|
109778
|
+
[1m[36mprimary::SchemaMigration Create (0.3ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181015143737"]]
|
109779
|
+
[1m[35m (1.2ms)[0m [1m[35mCOMMIT[0m
|
109780
|
+
Migrating to AddFileDataToModel (20181031190647)
|
109781
|
+
[1m[35m (0.9ms)[0m [1m[35mBEGIN[0m
|
109782
|
+
[1m[35m (0.6ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "file_data" jsonb[0m
|
109783
|
+
[1m[36mprimary::SchemaMigration Create (0.3ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181031190647"]]
|
109784
|
+
[1m[35m (5.4ms)[0m [1m[35mCOMMIT[0m
|
109785
|
+
Migrating to CreateKitheDerivatives (20181128185658)
|
109786
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
109787
|
+
[1m[35m (26.1ms)[0m [1m[35mCREATE TABLE "kithe_derivatives" ("id" bigserial primary key, "key" character varying NOT NULL, "file_data" jsonb, "asset_id" uuid NOT NULL, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL, CONSTRAINT "fk_rails_3dac8b4201"
|
109788
|
+
FOREIGN KEY ("asset_id")
|
109789
|
+
REFERENCES "kithe_models" ("id")
|
109790
|
+
)[0m
|
109791
|
+
[1m[35m (9.1ms)[0m [1m[35mCREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")[0m
|
109792
|
+
[1m[35m (1.1ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")[0m
|
109793
|
+
[1m[36mprimary::SchemaMigration Create (0.4ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181128185658"]]
|
109794
|
+
[1m[35m (0.6ms)[0m [1m[35mCOMMIT[0m
|
109795
|
+
Migrating to AddRepresentativeRelations (20190103144947)
|
109796
|
+
[1m[35m (6.4ms)[0m [1m[35mBEGIN[0m
|
109797
|
+
[1m[35m (0.5ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "representative_id" uuid[0m
|
109798
|
+
[1m[35m (7.1ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")[0m
|
109799
|
+
[1m[35m (4.8ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
|
109800
|
+
FOREIGN KEY ("representative_id")
|
109801
|
+
REFERENCES "kithe_models" ("id")
|
109802
|
+
[0m
|
109803
|
+
[1m[35m (0.6ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "leaf_representative_id" uuid[0m
|
109804
|
+
[1m[35m (7.0ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")[0m
|
109805
|
+
[1m[35m (1.8ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
|
109806
|
+
FOREIGN KEY ("leaf_representative_id")
|
109807
|
+
REFERENCES "kithe_models" ("id")
|
109808
|
+
[0m
|
109809
|
+
[1m[36mprimary::SchemaMigration Create (0.5ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20190103144947"]]
|
109810
|
+
[1m[35m (13.6ms)[0m [1m[35mCOMMIT[0m
|
109811
|
+
Migrating to ContainsAssociation (20190109192252)
|
109812
|
+
[1m[35m (0.3ms)[0m [1m[35mBEGIN[0m
|
109813
|
+
[1m[35m (3.2ms)[0m [1m[35mCREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid, CONSTRAINT "fk_rails_490c1158f7"
|
109814
|
+
FOREIGN KEY ("containee_id")
|
109815
|
+
REFERENCES "kithe_models" ("id")
|
109816
|
+
, CONSTRAINT "fk_rails_091010187b"
|
109817
|
+
FOREIGN KEY ("container_id")
|
109818
|
+
REFERENCES "kithe_models" ("id")
|
109819
|
+
)[0m
|
109820
|
+
[1m[35m (1.7ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")[0m
|
109821
|
+
[1m[35m (137.7ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")[0m
|
109822
|
+
[1m[36mprimary::SchemaMigration Create (0.8ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20190109192252"]]
|
109823
|
+
[1m[35m (0.6ms)[0m [1m[35mCOMMIT[0m
|
109824
|
+
Migrating to KitheModelType (20190404144551)
|
109825
|
+
[1m[35m (0.7ms)[0m [1m[35mBEGIN[0m
|
109826
|
+
[1m[35m (1.6ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "kithe_model_type" integer[0m
|
109827
|
+
[1m[35m (0.5ms)[0m [1m[34mSELECT "kithe_models"."id" FROM "kithe_models" ORDER BY "kithe_models"."id" ASC LIMIT $1[0m [["LIMIT", 1000]]
|
109828
|
+
[1m[35m (0.6ms)[0m [1m[35mALTER TABLE "kithe_models" ALTER COLUMN "kithe_model_type" TYPE integer, ALTER COLUMN "kithe_model_type" SET NOT NULL[0m
|
109829
|
+
[1m[36mprimary::SchemaMigration Create (0.4ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20190404144551"]]
|
109830
|
+
[1m[35m (15.6ms)[0m [1m[35mCOMMIT[0m
|
109831
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.4ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
109832
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
109833
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.5ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"[0m [["key", "environment"], ["value", "development"], ["created_at", "2020-05-27 16:05:23.911025"], ["updated_at", "2020-05-27 16:05:23.911025"]]
|
109834
|
+
[1m[35m (18.0ms)[0m [1m[35mCOMMIT[0m
|
109835
|
+
[1m[35m (0.8ms)[0m [1m[34mSELECT pg_advisory_unlock(1601470156486188030)[0m
|
109836
|
+
[1m[35m (1.0ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
109837
|
+
[1m[35m (5.4ms)[0m [1m[34m SELECT
|
109838
|
+
pp.proname AS name,
|
109839
|
+
pg_get_functiondef(pp.oid) AS definition
|
109840
|
+
FROM pg_proc pp
|
109841
|
+
JOIN pg_namespace pn
|
109842
|
+
ON pn.oid = pp.pronamespace
|
109843
|
+
LEFT JOIN pg_depend pd
|
109844
|
+
ON pd.objid = pp.oid AND pd.deptype = 'e'
|
109845
|
+
WHERE pn.nspname = 'public' AND pd.objid IS NULL
|
109846
|
+
ORDER BY pp.oid;
|
109847
|
+
[0m
|
109848
|
+
[1m[35m (1.5ms)[0m [1m[34m SELECT
|
109849
|
+
pt.tgname AS name,
|
109850
|
+
pg_get_triggerdef(pt.oid) AS definition
|
109851
|
+
FROM pg_trigger pt
|
109852
|
+
JOIN pg_class pc
|
109853
|
+
ON (pc.oid = pt.tgrelid)
|
109854
|
+
JOIN pg_proc pp
|
109855
|
+
ON (pp.oid = pt.tgfoid)
|
109856
|
+
WHERE pt.tgname
|
109857
|
+
NOT ILIKE '%constraint%' AND pt.tgname NOT ILIKE 'pg%'
|
109858
|
+
ORDER BY pc.oid;
|
109859
|
+
[0m
|
109860
|
+
[1m[35m (0.9ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
109861
|
+
[1m[35m (0.4ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
109862
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
109863
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
109864
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
109865
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
109866
|
+
[1m[35m (281.6ms)[0m [1m[35mDROP DATABASE IF EXISTS "kithe_development"[0m
|
109867
|
+
[1m[35m (206.0ms)[0m [1m[35mDROP DATABASE IF EXISTS "kithe_test"[0m
|
109868
|
+
[1m[35m (430.0ms)[0m [1m[35mCREATE DATABASE "kithe_development" ENCODING = 'unicode'[0m
|
109869
|
+
[1m[35m (507.9ms)[0m [1m[35mCREATE DATABASE "kithe_test" ENCODING = 'unicode'[0m
|
109870
|
+
[1m[35mSQL (44.1ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "pgcrypto"[0m
|
109871
|
+
[1m[35mSQL (0.2ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "plpgsql"[0m
|
109872
|
+
[1m[35m (2.2ms)[0m [1m[35mCREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint)
|
109873
|
+
RETURNS text
|
109874
|
+
LANGUAGE plpgsql
|
109875
|
+
AS $function$
|
109876
|
+
DECLARE
|
109877
|
+
new_id_int bigint;
|
109878
|
+
new_id_str character varying := '';
|
109879
|
+
done bool;
|
109880
|
+
tries integer;
|
109881
|
+
alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
|
109882
|
+
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
109883
|
+
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
|
109884
|
+
alphabet_length integer := array_length(alphabet, 1);
|
109885
|
+
|
109886
|
+
BEGIN
|
109887
|
+
done := false;
|
109888
|
+
tries := 0;
|
109889
|
+
WHILE (NOT done) LOOP
|
109890
|
+
tries := tries + 1;
|
109891
|
+
IF (tries > 3) THEN
|
109892
|
+
RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
|
109893
|
+
END IF;
|
109894
|
+
|
109895
|
+
new_id_int := trunc(random() * (max_value - min_value) + min_value);
|
109896
|
+
|
109897
|
+
-- convert bigint to a Base-36 alphanumeric string
|
109898
|
+
-- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
|
109899
|
+
-- https://gist.github.com/btbytes/7159902
|
109900
|
+
WHILE new_id_int != 0 LOOP
|
109901
|
+
new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
|
109902
|
+
new_id_int := new_id_int / alphabet_length;
|
109903
|
+
END LOOP;
|
109904
|
+
|
109905
|
+
done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
|
109906
|
+
END LOOP;
|
109907
|
+
RETURN new_id_str;
|
109908
|
+
END;
|
109909
|
+
$function$
|
109910
|
+
[0m
|
109911
|
+
[1m[35m (0.4ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_derivatives" CASCADE[0m
|
109912
|
+
[1m[35m (8.6ms)[0m [1m[35mCREATE 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)[0m
|
109913
|
+
[1m[35m (1.8ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")[0m
|
109914
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")[0m
|
109915
|
+
[1m[35m (0.2ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_model_contains" CASCADE[0m
|
109916
|
+
[1m[35m (1.8ms)[0m [1m[35mCREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid)[0m
|
109917
|
+
[1m[35m (1.4ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")[0m
|
109918
|
+
[1m[35m (1.3ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")[0m
|
109919
|
+
[1m[35m (0.2ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_models" CASCADE[0m
|
109920
|
+
[1m[35m (3.5ms)[0m [1m[35mCREATE 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)[0m
|
109921
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")[0m
|
109922
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")[0m
|
109923
|
+
[1m[35m (1.5ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")[0m
|
109924
|
+
[1m[35m (1.7ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")[0m
|
109925
|
+
[1m[35m (4.7ms)[0m [1m[35mALTER TABLE "kithe_derivatives" ADD CONSTRAINT "fk_rails_3dac8b4201"
|
109926
|
+
FOREIGN KEY ("asset_id")
|
109927
|
+
REFERENCES "kithe_models" ("id")
|
109928
|
+
[0m
|
109929
|
+
[1m[35m (4.2ms)[0m [1m[35mALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_490c1158f7"
|
109930
|
+
FOREIGN KEY ("containee_id")
|
109931
|
+
REFERENCES "kithe_models" ("id")
|
109932
|
+
[0m
|
109933
|
+
[1m[35m (1.7ms)[0m [1m[35mALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_091010187b"
|
109934
|
+
FOREIGN KEY ("container_id")
|
109935
|
+
REFERENCES "kithe_models" ("id")
|
109936
|
+
[0m
|
109937
|
+
[1m[35m (1.6ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
|
109938
|
+
FOREIGN KEY ("leaf_representative_id")
|
109939
|
+
REFERENCES "kithe_models" ("id")
|
109940
|
+
[0m
|
109941
|
+
[1m[35m (2.2ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
|
109942
|
+
FOREIGN KEY ("parent_id")
|
109943
|
+
REFERENCES "kithe_models" ("id")
|
109944
|
+
[0m
|
109945
|
+
[1m[35m (2.4ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
|
109946
|
+
FOREIGN KEY ("representative_id")
|
109947
|
+
REFERENCES "kithe_models" ("id")
|
109948
|
+
[0m
|
109949
|
+
[1m[35m (3.1ms)[0m [1m[35mCREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)[0m
|
109950
|
+
[1m[35m (0.7ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
109951
|
+
[1m[35m (0.8ms)[0m [1m[32mINSERT INTO "schema_migrations" (version) VALUES (20190404144551)[0m
|
109952
|
+
[1m[35m (1.1ms)[0m [1m[32mINSERT INTO "schema_migrations" (version) VALUES
|
109953
|
+
(20181015143259),
|
109954
|
+
(20181015143413),
|
109955
|
+
(20181015143737),
|
109956
|
+
(20181031190647),
|
109957
|
+
(20181128185658),
|
109958
|
+
(20190103144947),
|
109959
|
+
(20190109192252);
|
109960
|
+
|
109961
|
+
[0m
|
109962
|
+
[1m[35m (3.0ms)[0m [1m[35mCREATE 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)[0m
|
109963
|
+
[1m[36mActiveRecord::InternalMetadata Load (2.6ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
109964
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
109965
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.6ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"[0m [["key", "environment"], ["value", "development"], ["created_at", "2020-05-27 16:05:36.100092"], ["updated_at", "2020-05-27 16:05:36.100092"]]
|
109966
|
+
[1m[35m (6.3ms)[0m [1m[35mCOMMIT[0m
|
109967
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.3ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
109968
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.3ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "schema_sha1"], ["LIMIT", 1]]
|
109969
|
+
[1m[35m (0.1ms)[0m [1m[35mBEGIN[0m
|
109970
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.3ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"[0m [["key", "schema_sha1"], ["value", "0e24e2caa948e64f3be11233d707b8abffa0f356"], ["created_at", "2020-05-27 16:05:36.114811"], ["updated_at", "2020-05-27 16:05:36.114811"]]
|
109971
|
+
[1m[35m (5.0ms)[0m [1m[35mCOMMIT[0m
|
109972
|
+
[1m[35mSQL (43.0ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "pgcrypto"[0m
|
109973
|
+
[1m[35mSQL (0.9ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "plpgsql"[0m
|
109974
|
+
[1m[35m (2.4ms)[0m [1m[35mCREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint)
|
109975
|
+
RETURNS text
|
109976
|
+
LANGUAGE plpgsql
|
109977
|
+
AS $function$
|
109978
|
+
DECLARE
|
109979
|
+
new_id_int bigint;
|
109980
|
+
new_id_str character varying := '';
|
109981
|
+
done bool;
|
109982
|
+
tries integer;
|
109983
|
+
alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
|
109984
|
+
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
109985
|
+
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
|
109986
|
+
alphabet_length integer := array_length(alphabet, 1);
|
109987
|
+
|
109988
|
+
BEGIN
|
109989
|
+
done := false;
|
109990
|
+
tries := 0;
|
109991
|
+
WHILE (NOT done) LOOP
|
109992
|
+
tries := tries + 1;
|
109993
|
+
IF (tries > 3) THEN
|
109994
|
+
RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
|
109995
|
+
END IF;
|
109996
|
+
|
109997
|
+
new_id_int := trunc(random() * (max_value - min_value) + min_value);
|
109998
|
+
|
109999
|
+
-- convert bigint to a Base-36 alphanumeric string
|
110000
|
+
-- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
|
110001
|
+
-- https://gist.github.com/btbytes/7159902
|
110002
|
+
WHILE new_id_int != 0 LOOP
|
110003
|
+
new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
|
110004
|
+
new_id_int := new_id_int / alphabet_length;
|
110005
|
+
END LOOP;
|
110006
|
+
|
110007
|
+
done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
|
110008
|
+
END LOOP;
|
110009
|
+
RETURN new_id_str;
|
110010
|
+
END;
|
110011
|
+
$function$
|
110012
|
+
[0m
|
110013
|
+
[1m[35m (1.2ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_derivatives" CASCADE[0m
|
110014
|
+
[1m[35m (27.4ms)[0m [1m[35mCREATE 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)[0m
|
110015
|
+
[1m[35m (2.0ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")[0m
|
110016
|
+
[1m[35m (1.4ms)[0m [1m[35mCREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")[0m
|
110017
|
+
[1m[35m (0.2ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_model_contains" CASCADE[0m
|
110018
|
+
[1m[35m (3.5ms)[0m [1m[35mCREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid)[0m
|
110019
|
+
[1m[35m (2.0ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")[0m
|
110020
|
+
[1m[35m (1.7ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")[0m
|
110021
|
+
[1m[35m (0.5ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_models" CASCADE[0m
|
110022
|
+
[1m[35m (8.2ms)[0m [1m[35mCREATE 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)[0m
|
110023
|
+
[1m[35m (1.4ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")[0m
|
110024
|
+
[1m[35m (1.3ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")[0m
|
110025
|
+
[1m[35m (1.4ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")[0m
|
110026
|
+
[1m[35m (1.3ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")[0m
|
110027
|
+
[1m[35m (15.7ms)[0m [1m[35mALTER TABLE "kithe_derivatives" ADD CONSTRAINT "fk_rails_3dac8b4201"
|
110028
|
+
FOREIGN KEY ("asset_id")
|
110029
|
+
REFERENCES "kithe_models" ("id")
|
110030
|
+
[0m
|
110031
|
+
[1m[35m (2.2ms)[0m [1m[35mALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_490c1158f7"
|
110032
|
+
FOREIGN KEY ("containee_id")
|
110033
|
+
REFERENCES "kithe_models" ("id")
|
110034
|
+
[0m
|
110035
|
+
[1m[35m (3.1ms)[0m [1m[35mALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_091010187b"
|
110036
|
+
FOREIGN KEY ("container_id")
|
110037
|
+
REFERENCES "kithe_models" ("id")
|
110038
|
+
[0m
|
110039
|
+
[1m[35m (3.1ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
|
110040
|
+
FOREIGN KEY ("leaf_representative_id")
|
110041
|
+
REFERENCES "kithe_models" ("id")
|
110042
|
+
[0m
|
110043
|
+
[1m[35m (3.6ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
|
110044
|
+
FOREIGN KEY ("parent_id")
|
110045
|
+
REFERENCES "kithe_models" ("id")
|
110046
|
+
[0m
|
110047
|
+
[1m[35m (1.8ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
|
110048
|
+
FOREIGN KEY ("representative_id")
|
110049
|
+
REFERENCES "kithe_models" ("id")
|
110050
|
+
[0m
|
110051
|
+
[1m[35m (3.2ms)[0m [1m[35mCREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)[0m
|
110052
|
+
[1m[35m (0.7ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110053
|
+
[1m[35m (0.7ms)[0m [1m[32mINSERT INTO "schema_migrations" (version) VALUES (20190404144551)[0m
|
110054
|
+
[1m[35m (0.7ms)[0m [1m[32mINSERT INTO "schema_migrations" (version) VALUES
|
110055
|
+
(20181015143259),
|
110056
|
+
(20181015143413),
|
110057
|
+
(20181015143737),
|
110058
|
+
(20181031190647),
|
110059
|
+
(20181128185658),
|
110060
|
+
(20190103144947),
|
110061
|
+
(20190109192252);
|
110062
|
+
|
110063
|
+
[0m
|
110064
|
+
[1m[35m (3.5ms)[0m [1m[35mCREATE 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)[0m
|
110065
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.4ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
110066
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
110067
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.6ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"[0m [["key", "environment"], ["value", "development"], ["created_at", "2020-05-27 16:05:36.379857"], ["updated_at", "2020-05-27 16:05:36.379857"]]
|
110068
|
+
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
110069
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.7ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
110070
|
+
[1m[35m (0.3ms)[0m [1m[35mBEGIN[0m
|
110071
|
+
[1m[36mActiveRecord::InternalMetadata Update (1.3ms)[0m [1m[33mUPDATE "ar_internal_metadata" SET "value" = $1, "updated_at" = $2 WHERE "ar_internal_metadata"."key" = $3[0m [["value", "test"], ["updated_at", "2020-05-27 16:05:36.388452"], ["key", "environment"]]
|
110072
|
+
[1m[35m (0.6ms)[0m [1m[35mCOMMIT[0m
|
110073
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.7ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "schema_sha1"], ["LIMIT", 1]]
|
110074
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
110075
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.5ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"[0m [["key", "schema_sha1"], ["value", "0e24e2caa948e64f3be11233d707b8abffa0f356"], ["created_at", "2020-05-27 16:05:36.399100"], ["updated_at", "2020-05-27 16:05:36.399100"]]
|
110076
|
+
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
110077
|
+
[1m[35m (1.0ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110078
|
+
[1m[35m (0.5ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
110079
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110080
|
+
[1m[35m (0.7ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
110081
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110082
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
110083
|
+
[1m[35mSQL (0.3ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "pgcrypto"[0m
|
110084
|
+
[1m[35mSQL (0.8ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "plpgsql"[0m
|
110085
|
+
[1m[35m (3.0ms)[0m [1m[35mCREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint)
|
110086
|
+
RETURNS text
|
110087
|
+
LANGUAGE plpgsql
|
110088
|
+
AS $function$
|
110089
|
+
DECLARE
|
110090
|
+
new_id_int bigint;
|
110091
|
+
new_id_str character varying := '';
|
110092
|
+
done bool;
|
110093
|
+
tries integer;
|
110094
|
+
alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
|
110095
|
+
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
110096
|
+
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
|
110097
|
+
alphabet_length integer := array_length(alphabet, 1);
|
110098
|
+
|
110099
|
+
BEGIN
|
110100
|
+
done := false;
|
110101
|
+
tries := 0;
|
110102
|
+
WHILE (NOT done) LOOP
|
110103
|
+
tries := tries + 1;
|
110104
|
+
IF (tries > 3) THEN
|
110105
|
+
RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
|
110106
|
+
END IF;
|
110107
|
+
|
110108
|
+
new_id_int := trunc(random() * (max_value - min_value) + min_value);
|
110109
|
+
|
110110
|
+
-- convert bigint to a Base-36 alphanumeric string
|
110111
|
+
-- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
|
110112
|
+
-- https://gist.github.com/btbytes/7159902
|
110113
|
+
WHILE new_id_int != 0 LOOP
|
110114
|
+
new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
|
110115
|
+
new_id_int := new_id_int / alphabet_length;
|
110116
|
+
END LOOP;
|
110117
|
+
|
110118
|
+
done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
|
110119
|
+
END LOOP;
|
110120
|
+
RETURN new_id_str;
|
110121
|
+
END;
|
110122
|
+
$function$
|
110123
|
+
[0m
|
110124
|
+
[1m[35m (6.9ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_derivatives" CASCADE[0m
|
110125
|
+
[1m[35m (6.6ms)[0m [1m[35mCREATE 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)[0m
|
110126
|
+
[1m[35m (2.8ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")[0m
|
110127
|
+
[1m[35m (1.3ms)[0m [1m[35mCREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")[0m
|
110128
|
+
[1m[35m (2.9ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_model_contains" CASCADE[0m
|
110129
|
+
[1m[35m (1.5ms)[0m [1m[35mCREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid)[0m
|
110130
|
+
[1m[35m (1.6ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")[0m
|
110131
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")[0m
|
110132
|
+
[1m[35m (4.0ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_models" CASCADE[0m
|
110133
|
+
[1m[35m (4.1ms)[0m [1m[35mCREATE 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)[0m
|
110134
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")[0m
|
110135
|
+
[1m[35m (1.7ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")[0m
|
110136
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")[0m
|
110137
|
+
[1m[35m (3.3ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")[0m
|
110138
|
+
[1m[35m (15.9ms)[0m [1m[35mALTER TABLE "kithe_derivatives" ADD CONSTRAINT "fk_rails_3dac8b4201"
|
110139
|
+
FOREIGN KEY ("asset_id")
|
110140
|
+
REFERENCES "kithe_models" ("id")
|
110141
|
+
[0m
|
110142
|
+
[1m[35m (4.6ms)[0m [1m[35mALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_490c1158f7"
|
110143
|
+
FOREIGN KEY ("containee_id")
|
110144
|
+
REFERENCES "kithe_models" ("id")
|
110145
|
+
[0m
|
110146
|
+
[1m[35m (1.7ms)[0m [1m[35mALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_091010187b"
|
110147
|
+
FOREIGN KEY ("container_id")
|
110148
|
+
REFERENCES "kithe_models" ("id")
|
110149
|
+
[0m
|
110150
|
+
[1m[35m (1.7ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
|
110151
|
+
FOREIGN KEY ("leaf_representative_id")
|
110152
|
+
REFERENCES "kithe_models" ("id")
|
110153
|
+
[0m
|
110154
|
+
[1m[35m (3.6ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
|
110155
|
+
FOREIGN KEY ("parent_id")
|
110156
|
+
REFERENCES "kithe_models" ("id")
|
110157
|
+
[0m
|
110158
|
+
[1m[35m (1.9ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
|
110159
|
+
FOREIGN KEY ("representative_id")
|
110160
|
+
REFERENCES "kithe_models" ("id")
|
110161
|
+
[0m
|
110162
|
+
[1m[35m (0.7ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110163
|
+
[1m[36mActiveRecord::InternalMetadata Load (1.0ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
110164
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.3ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
110165
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.3ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "schema_sha1"], ["LIMIT", 1]]
|
110166
|
+
[1m[35mSQL (0.6ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "pgcrypto"[0m
|
110167
|
+
[1m[35mSQL (0.3ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "plpgsql"[0m
|
110168
|
+
[1m[35m (9.8ms)[0m [1m[35mCREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint)
|
110169
|
+
RETURNS text
|
110170
|
+
LANGUAGE plpgsql
|
110171
|
+
AS $function$
|
110172
|
+
DECLARE
|
110173
|
+
new_id_int bigint;
|
110174
|
+
new_id_str character varying := '';
|
110175
|
+
done bool;
|
110176
|
+
tries integer;
|
110177
|
+
alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
|
110178
|
+
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
110179
|
+
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
|
110180
|
+
alphabet_length integer := array_length(alphabet, 1);
|
110181
|
+
|
110182
|
+
BEGIN
|
110183
|
+
done := false;
|
110184
|
+
tries := 0;
|
110185
|
+
WHILE (NOT done) LOOP
|
110186
|
+
tries := tries + 1;
|
110187
|
+
IF (tries > 3) THEN
|
110188
|
+
RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
|
110189
|
+
END IF;
|
110190
|
+
|
110191
|
+
new_id_int := trunc(random() * (max_value - min_value) + min_value);
|
110192
|
+
|
110193
|
+
-- convert bigint to a Base-36 alphanumeric string
|
110194
|
+
-- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
|
110195
|
+
-- https://gist.github.com/btbytes/7159902
|
110196
|
+
WHILE new_id_int != 0 LOOP
|
110197
|
+
new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
|
110198
|
+
new_id_int := new_id_int / alphabet_length;
|
110199
|
+
END LOOP;
|
110200
|
+
|
110201
|
+
done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
|
110202
|
+
END LOOP;
|
110203
|
+
RETURN new_id_str;
|
110204
|
+
END;
|
110205
|
+
$function$
|
110206
|
+
[0m
|
110207
|
+
[1m[35m (23.1ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_derivatives" CASCADE[0m
|
110208
|
+
[1m[35m (43.6ms)[0m [1m[35mCREATE 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)[0m
|
110209
|
+
[1m[35m (16.1ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")[0m
|
110210
|
+
[1m[35m (21.5ms)[0m [1m[35mCREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")[0m
|
110211
|
+
[1m[35m (3.4ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_model_contains" CASCADE[0m
|
110212
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid)[0m
|
110213
|
+
[1m[35m (1.4ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")[0m
|
110214
|
+
[1m[35m (2.3ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")[0m
|
110215
|
+
[1m[35m (6.6ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_models" CASCADE[0m
|
110216
|
+
[1m[35m (6.7ms)[0m [1m[35mCREATE 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)[0m
|
110217
|
+
[1m[35m (1.4ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")[0m
|
110218
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")[0m
|
110219
|
+
[1m[35m (1.3ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")[0m
|
110220
|
+
[1m[35m (1.3ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")[0m
|
110221
|
+
[1m[35m (4.3ms)[0m [1m[35mALTER TABLE "kithe_derivatives" ADD CONSTRAINT "fk_rails_3dac8b4201"
|
110222
|
+
FOREIGN KEY ("asset_id")
|
110223
|
+
REFERENCES "kithe_models" ("id")
|
110224
|
+
[0m
|
110225
|
+
[1m[35m (3.0ms)[0m [1m[35mALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_490c1158f7"
|
110226
|
+
FOREIGN KEY ("containee_id")
|
110227
|
+
REFERENCES "kithe_models" ("id")
|
110228
|
+
[0m
|
110229
|
+
[1m[35m (2.3ms)[0m [1m[35mALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_091010187b"
|
110230
|
+
FOREIGN KEY ("container_id")
|
110231
|
+
REFERENCES "kithe_models" ("id")
|
110232
|
+
[0m
|
110233
|
+
[1m[35m (1.9ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
|
110234
|
+
FOREIGN KEY ("leaf_representative_id")
|
110235
|
+
REFERENCES "kithe_models" ("id")
|
110236
|
+
[0m
|
110237
|
+
[1m[35m (4.0ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
|
110238
|
+
FOREIGN KEY ("parent_id")
|
110239
|
+
REFERENCES "kithe_models" ("id")
|
110240
|
+
[0m
|
110241
|
+
[1m[35m (3.8ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
|
110242
|
+
FOREIGN KEY ("representative_id")
|
110243
|
+
REFERENCES "kithe_models" ("id")
|
110244
|
+
[0m
|
110245
|
+
[1m[35m (0.9ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110246
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.5ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
110247
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
110248
|
+
[1m[36mActiveRecord::InternalMetadata Update (0.4ms)[0m [1m[33mUPDATE "ar_internal_metadata" SET "value" = $1, "updated_at" = $2 WHERE "ar_internal_metadata"."key" = $3[0m [["value", "development"], ["updated_at", "2020-05-27 16:05:50.059067"], ["key", "environment"]]
|
110249
|
+
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
110250
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.3ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
110251
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
110252
|
+
[1m[36mActiveRecord::InternalMetadata Update (0.5ms)[0m [1m[33mUPDATE "ar_internal_metadata" SET "value" = $1, "updated_at" = $2 WHERE "ar_internal_metadata"."key" = $3[0m [["value", "test"], ["updated_at", "2020-05-27 16:05:50.071778"], ["key", "environment"]]
|
110253
|
+
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
110254
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.4ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "schema_sha1"], ["LIMIT", 1]]
|
110255
|
+
[1m[35m (0.9ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110256
|
+
[1m[35m (0.5ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
110257
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110258
|
+
[1m[35m (0.8ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
110259
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110260
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
110261
|
+
[1m[35m (215.0ms)[0m [1m[35mDROP DATABASE IF EXISTS "kithe_development"[0m
|
110262
|
+
[1m[35m (247.1ms)[0m [1m[35mDROP DATABASE IF EXISTS "kithe_test"[0m
|
110263
|
+
[1m[35m (572.0ms)[0m [1m[35mCREATE DATABASE "kithe_development" ENCODING = 'unicode'[0m
|
110264
|
+
[1m[35m (498.2ms)[0m [1m[35mCREATE DATABASE "kithe_test" ENCODING = 'unicode'[0m
|
110265
|
+
[1m[35m (15.1ms)[0m [1m[35mCREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)[0m
|
110266
|
+
[1m[35m (26.0ms)[0m [1m[35mCREATE 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)[0m
|
110267
|
+
[1m[35m (0.8ms)[0m [1m[34mSELECT pg_try_advisory_lock(1601470156486188030)[0m
|
110268
|
+
[1m[35m (0.8ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110269
|
+
Migrating to EnablePgcryptoExtension (20181015143259)
|
110270
|
+
[1m[35m (0.7ms)[0m [1m[35mBEGIN[0m
|
110271
|
+
[1m[35mSQL (29.6ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "pgcrypto"[0m
|
110272
|
+
[1m[36mprimary::SchemaMigration Create (0.6ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181015143259"]]
|
110273
|
+
[1m[35m (1.1ms)[0m [1m[35mCOMMIT[0m
|
110274
|
+
Migrating to CreateKitheModels (20181015143413)
|
110275
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
110276
|
+
[1m[35m (21.5ms)[0m [1m[35mCREATE 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)[0m
|
110277
|
+
[1m[35m (0.4ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "parent_id" uuid[0m
|
110278
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")[0m
|
110279
|
+
[1m[35m (2.3ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
|
110280
|
+
FOREIGN KEY ("parent_id")
|
110281
|
+
REFERENCES "kithe_models" ("id")
|
110282
|
+
[0m
|
110283
|
+
[1m[36mprimary::SchemaMigration Create (0.3ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181015143413"]]
|
110284
|
+
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
110285
|
+
Migrating to KitheModelsFriendlierId (20181015143737)
|
110286
|
+
[1m[35m (0.3ms)[0m [1m[35mBEGIN[0m
|
110287
|
+
[1m[35m (6.8ms)[0m [1m[35mCREATE OR REPLACE FUNCTION kithe_models_friendlier_id_gen(min_value bigint, max_value bigint) RETURNS text AS $$
|
110288
|
+
DECLARE
|
110289
|
+
new_id_int bigint;
|
110290
|
+
new_id_str character varying := '';
|
110291
|
+
done bool;
|
110292
|
+
tries integer;
|
110293
|
+
alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
|
110294
|
+
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
110295
|
+
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
|
110296
|
+
alphabet_length integer := array_length(alphabet, 1);
|
110297
|
+
|
110298
|
+
BEGIN
|
110299
|
+
done := false;
|
110300
|
+
tries := 0;
|
110301
|
+
WHILE (NOT done) LOOP
|
110302
|
+
tries := tries + 1;
|
110303
|
+
IF (tries > 3) THEN
|
110304
|
+
RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
|
110305
|
+
END IF;
|
110306
|
+
|
110307
|
+
new_id_int := trunc(random() * (max_value - min_value) + min_value);
|
110308
|
+
|
110309
|
+
-- convert bigint to a Base-36 alphanumeric string
|
110310
|
+
-- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
|
110311
|
+
-- https://gist.github.com/btbytes/7159902
|
110312
|
+
WHILE new_id_int != 0 LOOP
|
110313
|
+
new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
|
110314
|
+
new_id_int := new_id_int / alphabet_length;
|
110315
|
+
END LOOP;
|
110316
|
+
|
110317
|
+
done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
|
110318
|
+
END LOOP;
|
110319
|
+
RETURN new_id_str;
|
110320
|
+
END;
|
110321
|
+
$$ LANGUAGE plpgsql;
|
110322
|
+
[0m
|
110323
|
+
[1m[35m (25.2ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "friendlier_id" character varying DEFAULT kithe_models_friendlier_id_gen(2821109907456, 101559956668415) NOT NULL[0m
|
110324
|
+
[1m[35m (2.2ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")[0m
|
110325
|
+
[1m[36mprimary::SchemaMigration Create (0.4ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181015143737"]]
|
110326
|
+
[1m[35m (1.3ms)[0m [1m[35mCOMMIT[0m
|
110327
|
+
Migrating to AddFileDataToModel (20181031190647)
|
110328
|
+
[1m[35m (0.3ms)[0m [1m[35mBEGIN[0m
|
110329
|
+
[1m[35m (0.4ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "file_data" jsonb[0m
|
110330
|
+
[1m[36mprimary::SchemaMigration Create (0.4ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181031190647"]]
|
110331
|
+
[1m[35m (6.1ms)[0m [1m[35mCOMMIT[0m
|
110332
|
+
Migrating to CreateKitheDerivatives (20181128185658)
|
110333
|
+
[1m[35m (0.7ms)[0m [1m[35mBEGIN[0m
|
110334
|
+
[1m[35m (17.2ms)[0m [1m[35mCREATE TABLE "kithe_derivatives" ("id" bigserial primary key, "key" character varying NOT NULL, "file_data" jsonb, "asset_id" uuid NOT NULL, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL, CONSTRAINT "fk_rails_3dac8b4201"
|
110335
|
+
FOREIGN KEY ("asset_id")
|
110336
|
+
REFERENCES "kithe_models" ("id")
|
110337
|
+
)[0m
|
110338
|
+
[1m[35m (5.4ms)[0m [1m[35mCREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")[0m
|
110339
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")[0m
|
110340
|
+
[1m[36mprimary::SchemaMigration Create (0.3ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181128185658"]]
|
110341
|
+
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
110342
|
+
Migrating to AddRepresentativeRelations (20190103144947)
|
110343
|
+
[1m[35m (6.0ms)[0m [1m[35mBEGIN[0m
|
110344
|
+
[1m[35m (0.5ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "representative_id" uuid[0m
|
110345
|
+
[1m[35m (13.1ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")[0m
|
110346
|
+
[1m[35m (1.6ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
|
110347
|
+
FOREIGN KEY ("representative_id")
|
110348
|
+
REFERENCES "kithe_models" ("id")
|
110349
|
+
[0m
|
110350
|
+
[1m[35m (0.5ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "leaf_representative_id" uuid[0m
|
110351
|
+
[1m[35m (1.1ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")[0m
|
110352
|
+
[1m[35m (1.5ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
|
110353
|
+
FOREIGN KEY ("leaf_representative_id")
|
110354
|
+
REFERENCES "kithe_models" ("id")
|
110355
|
+
[0m
|
110356
|
+
[1m[36mprimary::SchemaMigration Create (0.5ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20190103144947"]]
|
110357
|
+
[1m[35m (0.9ms)[0m [1m[35mCOMMIT[0m
|
110358
|
+
Migrating to ContainsAssociation (20190109192252)
|
110359
|
+
[1m[35m (0.3ms)[0m [1m[35mBEGIN[0m
|
110360
|
+
[1m[35m (2.1ms)[0m [1m[35mCREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid, CONSTRAINT "fk_rails_490c1158f7"
|
110361
|
+
FOREIGN KEY ("containee_id")
|
110362
|
+
REFERENCES "kithe_models" ("id")
|
110363
|
+
, CONSTRAINT "fk_rails_091010187b"
|
110364
|
+
FOREIGN KEY ("container_id")
|
110365
|
+
REFERENCES "kithe_models" ("id")
|
110366
|
+
)[0m
|
110367
|
+
[1m[35m (7.2ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")[0m
|
110368
|
+
[1m[35m (7.7ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")[0m
|
110369
|
+
[1m[36mprimary::SchemaMigration Create (0.5ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20190109192252"]]
|
110370
|
+
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
110371
|
+
Migrating to KitheModelType (20190404144551)
|
110372
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
110373
|
+
[1m[35m (0.5ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "kithe_model_type" integer[0m
|
110374
|
+
[1m[35m (0.5ms)[0m [1m[34mSELECT "kithe_models"."id" FROM "kithe_models" ORDER BY "kithe_models"."id" ASC LIMIT $1[0m [["LIMIT", 1000]]
|
110375
|
+
[1m[35m (0.6ms)[0m [1m[35mALTER TABLE "kithe_models" ALTER COLUMN "kithe_model_type" TYPE integer, ALTER COLUMN "kithe_model_type" SET NOT NULL[0m
|
110376
|
+
[1m[36mprimary::SchemaMigration Create (0.4ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20190404144551"]]
|
110377
|
+
[1m[35m (6.4ms)[0m [1m[35mCOMMIT[0m
|
110378
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.6ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
110379
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
110380
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.6ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"[0m [["key", "environment"], ["value", "development"], ["created_at", "2020-05-27 16:15:23.265055"], ["updated_at", "2020-05-27 16:15:23.265055"]]
|
110381
|
+
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
110382
|
+
[1m[35m (0.5ms)[0m [1m[34mSELECT pg_advisory_unlock(1601470156486188030)[0m
|
110383
|
+
[1m[35m (1.6ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110384
|
+
[1m[35m (4.8ms)[0m [1m[34m SELECT
|
110385
|
+
pp.proname AS name,
|
110386
|
+
pg_get_functiondef(pp.oid) AS definition
|
110387
|
+
FROM pg_proc pp
|
110388
|
+
JOIN pg_namespace pn
|
110389
|
+
ON pn.oid = pp.pronamespace
|
110390
|
+
LEFT JOIN pg_depend pd
|
110391
|
+
ON pd.objid = pp.oid AND pd.deptype = 'e'
|
110392
|
+
WHERE pn.nspname = 'public' AND pd.objid IS NULL
|
110393
|
+
ORDER BY pp.oid;
|
110394
|
+
[0m
|
110395
|
+
[1m[35m (1.5ms)[0m [1m[34m SELECT
|
110396
|
+
pt.tgname AS name,
|
110397
|
+
pg_get_triggerdef(pt.oid) AS definition
|
110398
|
+
FROM pg_trigger pt
|
110399
|
+
JOIN pg_class pc
|
110400
|
+
ON (pc.oid = pt.tgrelid)
|
110401
|
+
JOIN pg_proc pp
|
110402
|
+
ON (pp.oid = pt.tgfoid)
|
110403
|
+
WHERE pt.tgname
|
110404
|
+
NOT ILIKE '%constraint%' AND pt.tgname NOT ILIKE 'pg%'
|
110405
|
+
ORDER BY pc.oid;
|
110406
|
+
[0m
|
110407
|
+
[1m[35m (1.3ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110408
|
+
[1m[35m (0.5ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
110409
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110410
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
110411
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110412
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
110413
|
+
[1m[35m (207.6ms)[0m [1m[35mDROP DATABASE IF EXISTS "kithe_development"[0m
|
110414
|
+
[1m[35m (204.7ms)[0m [1m[35mDROP DATABASE IF EXISTS "kithe_test"[0m
|
110415
|
+
[1m[35m (434.7ms)[0m [1m[35mCREATE DATABASE "kithe_development" ENCODING = 'unicode'[0m
|
110416
|
+
[1m[35m (556.2ms)[0m [1m[35mCREATE DATABASE "kithe_test" ENCODING = 'unicode'[0m
|
110417
|
+
[1m[35mSQL (13.4ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "pgcrypto"[0m
|
110418
|
+
[1m[35mSQL (0.5ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "plpgsql"[0m
|
110419
|
+
[1m[35m (2.7ms)[0m [1m[35mCREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint)
|
110420
|
+
RETURNS text
|
110421
|
+
LANGUAGE plpgsql
|
110422
|
+
AS $function$
|
110423
|
+
DECLARE
|
110424
|
+
new_id_int bigint;
|
110425
|
+
new_id_str character varying := '';
|
110426
|
+
done bool;
|
110427
|
+
tries integer;
|
110428
|
+
alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
|
110429
|
+
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
110430
|
+
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
|
110431
|
+
alphabet_length integer := array_length(alphabet, 1);
|
110432
|
+
|
110433
|
+
BEGIN
|
110434
|
+
done := false;
|
110435
|
+
tries := 0;
|
110436
|
+
WHILE (NOT done) LOOP
|
110437
|
+
tries := tries + 1;
|
110438
|
+
IF (tries > 3) THEN
|
110439
|
+
RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
|
110440
|
+
END IF;
|
110441
|
+
|
110442
|
+
new_id_int := trunc(random() * (max_value - min_value) + min_value);
|
110443
|
+
|
110444
|
+
-- convert bigint to a Base-36 alphanumeric string
|
110445
|
+
-- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
|
110446
|
+
-- https://gist.github.com/btbytes/7159902
|
110447
|
+
WHILE new_id_int != 0 LOOP
|
110448
|
+
new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
|
110449
|
+
new_id_int := new_id_int / alphabet_length;
|
110450
|
+
END LOOP;
|
110451
|
+
|
110452
|
+
done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
|
110453
|
+
END LOOP;
|
110454
|
+
RETURN new_id_str;
|
110455
|
+
END;
|
110456
|
+
$function$
|
110457
|
+
[0m
|
110458
|
+
[1m[35m (0.3ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_derivatives" CASCADE[0m
|
110459
|
+
[1m[35m (7.5ms)[0m [1m[35mCREATE 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)[0m
|
110460
|
+
[1m[35m (1.8ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")[0m
|
110461
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")[0m
|
110462
|
+
[1m[35m (0.2ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_model_contains" CASCADE[0m
|
110463
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid)[0m
|
110464
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")[0m
|
110465
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")[0m
|
110466
|
+
[1m[35m (0.4ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_models" CASCADE[0m
|
110467
|
+
[1m[35m (7.7ms)[0m [1m[35mCREATE 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)[0m
|
110468
|
+
[1m[35m (2.5ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")[0m
|
110469
|
+
[1m[35m (1.3ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")[0m
|
110470
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")[0m
|
110471
|
+
[1m[35m (1.9ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")[0m
|
110472
|
+
[1m[35m (3.3ms)[0m [1m[35mALTER TABLE "kithe_derivatives" ADD CONSTRAINT "fk_rails_3dac8b4201"
|
110473
|
+
FOREIGN KEY ("asset_id")
|
110474
|
+
REFERENCES "kithe_models" ("id")
|
110475
|
+
[0m
|
110476
|
+
[1m[35m (1.8ms)[0m [1m[35mALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_490c1158f7"
|
110477
|
+
FOREIGN KEY ("containee_id")
|
110478
|
+
REFERENCES "kithe_models" ("id")
|
110479
|
+
[0m
|
110480
|
+
[1m[35m (2.1ms)[0m [1m[35mALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_091010187b"
|
110481
|
+
FOREIGN KEY ("container_id")
|
110482
|
+
REFERENCES "kithe_models" ("id")
|
110483
|
+
[0m
|
110484
|
+
[1m[35m (1.7ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
|
110485
|
+
FOREIGN KEY ("leaf_representative_id")
|
110486
|
+
REFERENCES "kithe_models" ("id")
|
110487
|
+
[0m
|
110488
|
+
[1m[35m (2.1ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
|
110489
|
+
FOREIGN KEY ("parent_id")
|
110490
|
+
REFERENCES "kithe_models" ("id")
|
110491
|
+
[0m
|
110492
|
+
[1m[35m (2.1ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
|
110493
|
+
FOREIGN KEY ("representative_id")
|
110494
|
+
REFERENCES "kithe_models" ("id")
|
110495
|
+
[0m
|
110496
|
+
[1m[35m (6.4ms)[0m [1m[35mCREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)[0m
|
110497
|
+
[1m[35m (1.3ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110498
|
+
[1m[35m (1.0ms)[0m [1m[32mINSERT INTO "schema_migrations" (version) VALUES (20190404144551)[0m
|
110499
|
+
[1m[35m (0.9ms)[0m [1m[32mINSERT INTO "schema_migrations" (version) VALUES
|
110500
|
+
(20181015143259),
|
110501
|
+
(20181015143413),
|
110502
|
+
(20181015143737),
|
110503
|
+
(20181031190647),
|
110504
|
+
(20181128185658),
|
110505
|
+
(20190103144947),
|
110506
|
+
(20190109192252);
|
110507
|
+
|
110508
|
+
[0m
|
110509
|
+
[1m[35m (3.7ms)[0m [1m[35mCREATE 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)[0m
|
110510
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.4ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
110511
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
110512
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.6ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"[0m [["key", "environment"], ["value", "development"], ["created_at", "2020-05-27 16:15:41.046597"], ["updated_at", "2020-05-27 16:15:41.046597"]]
|
110513
|
+
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
110514
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.3ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
110515
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.3ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "schema_sha1"], ["LIMIT", 1]]
|
110516
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
110517
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.5ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"[0m [["key", "schema_sha1"], ["value", "0e24e2caa948e64f3be11233d707b8abffa0f356"], ["created_at", "2020-05-27 16:15:41.055003"], ["updated_at", "2020-05-27 16:15:41.055003"]]
|
110518
|
+
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
110519
|
+
[1m[35mSQL (17.0ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "pgcrypto"[0m
|
110520
|
+
[1m[35mSQL (0.2ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "plpgsql"[0m
|
110521
|
+
[1m[35m (9.5ms)[0m [1m[35mCREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint)
|
110522
|
+
RETURNS text
|
110523
|
+
LANGUAGE plpgsql
|
110524
|
+
AS $function$
|
110525
|
+
DECLARE
|
110526
|
+
new_id_int bigint;
|
110527
|
+
new_id_str character varying := '';
|
110528
|
+
done bool;
|
110529
|
+
tries integer;
|
110530
|
+
alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
|
110531
|
+
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
110532
|
+
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
|
110533
|
+
alphabet_length integer := array_length(alphabet, 1);
|
110534
|
+
|
110535
|
+
BEGIN
|
110536
|
+
done := false;
|
110537
|
+
tries := 0;
|
110538
|
+
WHILE (NOT done) LOOP
|
110539
|
+
tries := tries + 1;
|
110540
|
+
IF (tries > 3) THEN
|
110541
|
+
RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
|
110542
|
+
END IF;
|
110543
|
+
|
110544
|
+
new_id_int := trunc(random() * (max_value - min_value) + min_value);
|
110545
|
+
|
110546
|
+
-- convert bigint to a Base-36 alphanumeric string
|
110547
|
+
-- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
|
110548
|
+
-- https://gist.github.com/btbytes/7159902
|
110549
|
+
WHILE new_id_int != 0 LOOP
|
110550
|
+
new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
|
110551
|
+
new_id_int := new_id_int / alphabet_length;
|
110552
|
+
END LOOP;
|
110553
|
+
|
110554
|
+
done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
|
110555
|
+
END LOOP;
|
110556
|
+
RETURN new_id_str;
|
110557
|
+
END;
|
110558
|
+
$function$
|
110559
|
+
[0m
|
110560
|
+
[1m[35m (0.5ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_derivatives" CASCADE[0m
|
110561
|
+
[1m[35m (8.3ms)[0m [1m[35mCREATE 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)[0m
|
110562
|
+
[1m[35m (1.9ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")[0m
|
110563
|
+
[1m[35m (1.3ms)[0m [1m[35mCREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")[0m
|
110564
|
+
[1m[35m (0.3ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_model_contains" CASCADE[0m
|
110565
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid)[0m
|
110566
|
+
[1m[35m (1.7ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")[0m
|
110567
|
+
[1m[35m (1.3ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")[0m
|
110568
|
+
[1m[35m (0.2ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_models" CASCADE[0m
|
110569
|
+
[1m[35m (6.3ms)[0m [1m[35mCREATE 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)[0m
|
110570
|
+
[1m[35m (2.7ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")[0m
|
110571
|
+
[1m[35m (1.5ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")[0m
|
110572
|
+
[1m[35m (1.3ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")[0m
|
110573
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")[0m
|
110574
|
+
[1m[35m (3.6ms)[0m [1m[35mALTER TABLE "kithe_derivatives" ADD CONSTRAINT "fk_rails_3dac8b4201"
|
110575
|
+
FOREIGN KEY ("asset_id")
|
110576
|
+
REFERENCES "kithe_models" ("id")
|
110577
|
+
[0m
|
110578
|
+
[1m[35m (1.9ms)[0m [1m[35mALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_490c1158f7"
|
110579
|
+
FOREIGN KEY ("containee_id")
|
110580
|
+
REFERENCES "kithe_models" ("id")
|
110581
|
+
[0m
|
110582
|
+
[1m[35m (1.7ms)[0m [1m[35mALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_091010187b"
|
110583
|
+
FOREIGN KEY ("container_id")
|
110584
|
+
REFERENCES "kithe_models" ("id")
|
110585
|
+
[0m
|
110586
|
+
[1m[35m (1.7ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
|
110587
|
+
FOREIGN KEY ("leaf_representative_id")
|
110588
|
+
REFERENCES "kithe_models" ("id")
|
110589
|
+
[0m
|
110590
|
+
[1m[35m (1.7ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
|
110591
|
+
FOREIGN KEY ("parent_id")
|
110592
|
+
REFERENCES "kithe_models" ("id")
|
110593
|
+
[0m
|
110594
|
+
[1m[35m (2.0ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
|
110595
|
+
FOREIGN KEY ("representative_id")
|
110596
|
+
REFERENCES "kithe_models" ("id")
|
110597
|
+
[0m
|
110598
|
+
[1m[35m (3.1ms)[0m [1m[35mCREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)[0m
|
110599
|
+
[1m[35m (0.8ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110600
|
+
[1m[35m (0.8ms)[0m [1m[32mINSERT INTO "schema_migrations" (version) VALUES (20190404144551)[0m
|
110601
|
+
[1m[35m (0.7ms)[0m [1m[32mINSERT INTO "schema_migrations" (version) VALUES
|
110602
|
+
(20181015143259),
|
110603
|
+
(20181015143413),
|
110604
|
+
(20181015143737),
|
110605
|
+
(20181031190647),
|
110606
|
+
(20181128185658),
|
110607
|
+
(20190103144947),
|
110608
|
+
(20190109192252);
|
110609
|
+
|
110610
|
+
[0m
|
110611
|
+
[1m[35m (4.7ms)[0m [1m[35mCREATE 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)[0m
|
110612
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.5ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
110613
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
110614
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.6ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"[0m [["key", "environment"], ["value", "development"], ["created_at", "2020-05-27 16:15:41.295599"], ["updated_at", "2020-05-27 16:15:41.295599"]]
|
110615
|
+
[1m[35m (0.9ms)[0m [1m[35mCOMMIT[0m
|
110616
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.3ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
110617
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
110618
|
+
[1m[36mActiveRecord::InternalMetadata Update (0.4ms)[0m [1m[33mUPDATE "ar_internal_metadata" SET "value" = $1, "updated_at" = $2 WHERE "ar_internal_metadata"."key" = $3[0m [["value", "test"], ["updated_at", "2020-05-27 16:15:41.302574"], ["key", "environment"]]
|
110619
|
+
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
110620
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.4ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "schema_sha1"], ["LIMIT", 1]]
|
110621
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
110622
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.4ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"[0m [["key", "schema_sha1"], ["value", "0e24e2caa948e64f3be11233d707b8abffa0f356"], ["created_at", "2020-05-27 16:15:41.308393"], ["updated_at", "2020-05-27 16:15:41.308393"]]
|
110623
|
+
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
110624
|
+
[1m[35m (0.9ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110625
|
+
[1m[35m (0.5ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
110626
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110627
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
110628
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110629
|
+
[1m[35m (0.7ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
110630
|
+
[1m[35m (217.9ms)[0m [1m[35mDROP DATABASE IF EXISTS "kithe_development"[0m
|
110631
|
+
[1m[35m (219.9ms)[0m [1m[35mDROP DATABASE IF EXISTS "kithe_test"[0m
|
110632
|
+
[1m[35m (498.0ms)[0m [1m[35mCREATE DATABASE "kithe_development" ENCODING = 'unicode'[0m
|
110633
|
+
[1m[35m (549.0ms)[0m [1m[35mCREATE DATABASE "kithe_test" ENCODING = 'unicode'[0m
|
110634
|
+
[1m[35m (16.4ms)[0m [1m[35mCREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)[0m
|
110635
|
+
[1m[35m (111.0ms)[0m [1m[35mCREATE 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)[0m
|
110636
|
+
[1m[35m (1.1ms)[0m [1m[34mSELECT pg_try_advisory_lock(1601470156486188030)[0m
|
110637
|
+
[1m[35m (0.7ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110638
|
+
Migrating to EnablePgcryptoExtension (20181015143259)
|
110639
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
110640
|
+
[1m[35mSQL (13.7ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "pgcrypto"[0m
|
110641
|
+
[1m[36mprimary::SchemaMigration Create (20.8ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181015143259"]]
|
110642
|
+
[1m[35m (2.0ms)[0m [1m[35mCOMMIT[0m
|
110643
|
+
Migrating to CreateKitheModels (20181015143413)
|
110644
|
+
[1m[35m (0.5ms)[0m [1m[35mBEGIN[0m
|
110645
|
+
[1m[35m (5.5ms)[0m [1m[35mCREATE 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)[0m
|
110646
|
+
[1m[35m (0.6ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "parent_id" uuid[0m
|
110647
|
+
[1m[35m (1.7ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")[0m
|
110648
|
+
[1m[35m (4.4ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
|
110649
|
+
FOREIGN KEY ("parent_id")
|
110650
|
+
REFERENCES "kithe_models" ("id")
|
110651
|
+
[0m
|
110652
|
+
[1m[36mprimary::SchemaMigration Create (0.5ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181015143413"]]
|
110653
|
+
[1m[35m (0.7ms)[0m [1m[35mCOMMIT[0m
|
110654
|
+
Migrating to KitheModelsFriendlierId (20181015143737)
|
110655
|
+
[1m[35m (0.3ms)[0m [1m[35mBEGIN[0m
|
110656
|
+
[1m[35m (8.1ms)[0m [1m[35mCREATE OR REPLACE FUNCTION kithe_models_friendlier_id_gen(min_value bigint, max_value bigint) RETURNS text AS $$
|
110657
|
+
DECLARE
|
110658
|
+
new_id_int bigint;
|
110659
|
+
new_id_str character varying := '';
|
110660
|
+
done bool;
|
110661
|
+
tries integer;
|
110662
|
+
alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
|
110663
|
+
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
110664
|
+
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
|
110665
|
+
alphabet_length integer := array_length(alphabet, 1);
|
110666
|
+
|
110667
|
+
BEGIN
|
110668
|
+
done := false;
|
110669
|
+
tries := 0;
|
110670
|
+
WHILE (NOT done) LOOP
|
110671
|
+
tries := tries + 1;
|
110672
|
+
IF (tries > 3) THEN
|
110673
|
+
RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
|
110674
|
+
END IF;
|
110675
|
+
|
110676
|
+
new_id_int := trunc(random() * (max_value - min_value) + min_value);
|
110677
|
+
|
110678
|
+
-- convert bigint to a Base-36 alphanumeric string
|
110679
|
+
-- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
|
110680
|
+
-- https://gist.github.com/btbytes/7159902
|
110681
|
+
WHILE new_id_int != 0 LOOP
|
110682
|
+
new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
|
110683
|
+
new_id_int := new_id_int / alphabet_length;
|
110684
|
+
END LOOP;
|
110685
|
+
|
110686
|
+
done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
|
110687
|
+
END LOOP;
|
110688
|
+
RETURN new_id_str;
|
110689
|
+
END;
|
110690
|
+
$$ LANGUAGE plpgsql;
|
110691
|
+
[0m
|
110692
|
+
[1m[35m (5.6ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "friendlier_id" character varying DEFAULT kithe_models_friendlier_id_gen(2821109907456, 101559956668415) NOT NULL[0m
|
110693
|
+
[1m[35m (1.0ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")[0m
|
110694
|
+
[1m[36mprimary::SchemaMigration Create (0.4ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181015143737"]]
|
110695
|
+
[1m[35m (1.1ms)[0m [1m[35mCOMMIT[0m
|
110696
|
+
Migrating to AddFileDataToModel (20181031190647)
|
110697
|
+
[1m[35m (0.3ms)[0m [1m[35mBEGIN[0m
|
110698
|
+
[1m[35m (0.4ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "file_data" jsonb[0m
|
110699
|
+
[1m[36mprimary::SchemaMigration Create (0.3ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181031190647"]]
|
110700
|
+
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
110701
|
+
Migrating to CreateKitheDerivatives (20181128185658)
|
110702
|
+
[1m[35m (0.3ms)[0m [1m[35mBEGIN[0m
|
110703
|
+
[1m[35m (7.2ms)[0m [1m[35mCREATE TABLE "kithe_derivatives" ("id" bigserial primary key, "key" character varying NOT NULL, "file_data" jsonb, "asset_id" uuid NOT NULL, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL, CONSTRAINT "fk_rails_3dac8b4201"
|
110704
|
+
FOREIGN KEY ("asset_id")
|
110705
|
+
REFERENCES "kithe_models" ("id")
|
110706
|
+
)[0m
|
110707
|
+
[1m[35m (1.4ms)[0m [1m[35mCREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")[0m
|
110708
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")[0m
|
110709
|
+
[1m[36mprimary::SchemaMigration Create (0.4ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181128185658"]]
|
110710
|
+
[1m[35m (0.7ms)[0m [1m[35mCOMMIT[0m
|
110711
|
+
Migrating to AddRepresentativeRelations (20190103144947)
|
110712
|
+
[1m[35m (3.1ms)[0m [1m[35mBEGIN[0m
|
110713
|
+
[1m[35m (1.3ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "representative_id" uuid[0m
|
110714
|
+
[1m[35m (1.4ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")[0m
|
110715
|
+
[1m[35m (2.3ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
|
110716
|
+
FOREIGN KEY ("representative_id")
|
110717
|
+
REFERENCES "kithe_models" ("id")
|
110718
|
+
[0m
|
110719
|
+
[1m[35m (0.5ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "leaf_representative_id" uuid[0m
|
110720
|
+
[1m[35m (1.5ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")[0m
|
110721
|
+
[1m[35m (3.5ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
|
110722
|
+
FOREIGN KEY ("leaf_representative_id")
|
110723
|
+
REFERENCES "kithe_models" ("id")
|
110724
|
+
[0m
|
110725
|
+
[1m[36mprimary::SchemaMigration Create (0.5ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20190103144947"]]
|
110726
|
+
[1m[35m (5.4ms)[0m [1m[35mCOMMIT[0m
|
110727
|
+
Migrating to ContainsAssociation (20190109192252)
|
110728
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
110729
|
+
[1m[35m (2.3ms)[0m [1m[35mCREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid, CONSTRAINT "fk_rails_490c1158f7"
|
110730
|
+
FOREIGN KEY ("containee_id")
|
110731
|
+
REFERENCES "kithe_models" ("id")
|
110732
|
+
, CONSTRAINT "fk_rails_091010187b"
|
110733
|
+
FOREIGN KEY ("container_id")
|
110734
|
+
REFERENCES "kithe_models" ("id")
|
110735
|
+
)[0m
|
110736
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")[0m
|
110737
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")[0m
|
110738
|
+
[1m[36mprimary::SchemaMigration Create (0.5ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20190109192252"]]
|
110739
|
+
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
110740
|
+
Migrating to KitheModelType (20190404144551)
|
110741
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
110742
|
+
[1m[35m (0.4ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "kithe_model_type" integer[0m
|
110743
|
+
[1m[35m (0.6ms)[0m [1m[34mSELECT "kithe_models"."id" FROM "kithe_models" ORDER BY "kithe_models"."id" ASC LIMIT $1[0m [["LIMIT", 1000]]
|
110744
|
+
[1m[35m (0.5ms)[0m [1m[35mALTER TABLE "kithe_models" ALTER COLUMN "kithe_model_type" TYPE integer, ALTER COLUMN "kithe_model_type" SET NOT NULL[0m
|
110745
|
+
[1m[36mprimary::SchemaMigration Create (0.3ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20190404144551"]]
|
110746
|
+
[1m[35m (0.7ms)[0m [1m[35mCOMMIT[0m
|
110747
|
+
[1m[36mActiveRecord::InternalMetadata Load (1.0ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
110748
|
+
[1m[35m (0.1ms)[0m [1m[35mBEGIN[0m
|
110749
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.6ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"[0m [["key", "environment"], ["value", "development"], ["created_at", "2020-05-27 16:16:55.002081"], ["updated_at", "2020-05-27 16:16:55.002081"]]
|
110750
|
+
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
110751
|
+
[1m[35m (0.5ms)[0m [1m[34mSELECT pg_advisory_unlock(1601470156486188030)[0m
|
110752
|
+
[1m[35m (0.9ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110753
|
+
[1m[35m (5.2ms)[0m [1m[34m SELECT
|
110754
|
+
pp.proname AS name,
|
110755
|
+
pg_get_functiondef(pp.oid) AS definition
|
110756
|
+
FROM pg_proc pp
|
110757
|
+
JOIN pg_namespace pn
|
110758
|
+
ON pn.oid = pp.pronamespace
|
110759
|
+
LEFT JOIN pg_depend pd
|
110760
|
+
ON pd.objid = pp.oid AND pd.deptype = 'e'
|
110761
|
+
WHERE pn.nspname = 'public' AND pd.objid IS NULL
|
110762
|
+
ORDER BY pp.oid;
|
110763
|
+
[0m
|
110764
|
+
[1m[35m (2.2ms)[0m [1m[34m SELECT
|
110765
|
+
pt.tgname AS name,
|
110766
|
+
pg_get_triggerdef(pt.oid) AS definition
|
110767
|
+
FROM pg_trigger pt
|
110768
|
+
JOIN pg_class pc
|
110769
|
+
ON (pc.oid = pt.tgrelid)
|
110770
|
+
JOIN pg_proc pp
|
110771
|
+
ON (pp.oid = pt.tgfoid)
|
110772
|
+
WHERE pt.tgname
|
110773
|
+
NOT ILIKE '%constraint%' AND pt.tgname NOT ILIKE 'pg%'
|
110774
|
+
ORDER BY pc.oid;
|
110775
|
+
[0m
|
110776
|
+
[1m[35m (1.5ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110777
|
+
[1m[35m (0.5ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
110778
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110779
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
110780
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110781
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
110782
|
+
[1m[35m (205.7ms)[0m [1m[35mDROP DATABASE IF EXISTS "kithe_development"[0m
|
110783
|
+
[1m[35m (212.8ms)[0m [1m[35mDROP DATABASE IF EXISTS "kithe_test"[0m
|
110784
|
+
[1m[35m (538.0ms)[0m [1m[35mCREATE DATABASE "kithe_development" ENCODING = 'unicode'[0m
|
110785
|
+
[1m[35m (495.1ms)[0m [1m[35mCREATE DATABASE "kithe_test" ENCODING = 'unicode'[0m
|
110786
|
+
[1m[35m (54.0ms)[0m [1m[35mCREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)[0m
|
110787
|
+
[1m[35m (5.6ms)[0m [1m[35mCREATE 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)[0m
|
110788
|
+
[1m[35m (0.4ms)[0m [1m[34mSELECT pg_try_advisory_lock(1601470156486188030)[0m
|
110789
|
+
[1m[35m (0.7ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110790
|
+
Migrating to EnablePgcryptoExtension (20181015143259)
|
110791
|
+
[1m[35m (0.3ms)[0m [1m[35mBEGIN[0m
|
110792
|
+
[1m[35mSQL (21.7ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "pgcrypto"[0m
|
110793
|
+
[1m[36mprimary::SchemaMigration Create (1.7ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181015143259"]]
|
110794
|
+
[1m[35m (2.1ms)[0m [1m[35mCOMMIT[0m
|
110795
|
+
Migrating to CreateKitheModels (20181015143413)
|
110796
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
110797
|
+
[1m[35m (4.0ms)[0m [1m[35mCREATE 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)[0m
|
110798
|
+
[1m[35m (0.8ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "parent_id" uuid[0m
|
110799
|
+
[1m[35m (1.4ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")[0m
|
110800
|
+
[1m[35m (2.5ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
|
110801
|
+
FOREIGN KEY ("parent_id")
|
110802
|
+
REFERENCES "kithe_models" ("id")
|
110803
|
+
[0m
|
110804
|
+
[1m[36mprimary::SchemaMigration Create (0.4ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181015143413"]]
|
110805
|
+
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
110806
|
+
Migrating to KitheModelsFriendlierId (20181015143737)
|
110807
|
+
[1m[35m (0.4ms)[0m [1m[35mBEGIN[0m
|
110808
|
+
[1m[35m (7.4ms)[0m [1m[35mCREATE OR REPLACE FUNCTION kithe_models_friendlier_id_gen(min_value bigint, max_value bigint) RETURNS text AS $$
|
110809
|
+
DECLARE
|
110810
|
+
new_id_int bigint;
|
110811
|
+
new_id_str character varying := '';
|
110812
|
+
done bool;
|
110813
|
+
tries integer;
|
110814
|
+
alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
|
110815
|
+
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
110816
|
+
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
|
110817
|
+
alphabet_length integer := array_length(alphabet, 1);
|
110818
|
+
|
110819
|
+
BEGIN
|
110820
|
+
done := false;
|
110821
|
+
tries := 0;
|
110822
|
+
WHILE (NOT done) LOOP
|
110823
|
+
tries := tries + 1;
|
110824
|
+
IF (tries > 3) THEN
|
110825
|
+
RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
|
110826
|
+
END IF;
|
110827
|
+
|
110828
|
+
new_id_int := trunc(random() * (max_value - min_value) + min_value);
|
110829
|
+
|
110830
|
+
-- convert bigint to a Base-36 alphanumeric string
|
110831
|
+
-- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
|
110832
|
+
-- https://gist.github.com/btbytes/7159902
|
110833
|
+
WHILE new_id_int != 0 LOOP
|
110834
|
+
new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
|
110835
|
+
new_id_int := new_id_int / alphabet_length;
|
110836
|
+
END LOOP;
|
110837
|
+
|
110838
|
+
done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
|
110839
|
+
END LOOP;
|
110840
|
+
RETURN new_id_str;
|
110841
|
+
END;
|
110842
|
+
$$ LANGUAGE plpgsql;
|
110843
|
+
[0m
|
110844
|
+
[1m[35m (20.1ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "friendlier_id" character varying DEFAULT kithe_models_friendlier_id_gen(2821109907456, 101559956668415) NOT NULL[0m
|
110845
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")[0m
|
110846
|
+
[1m[36mprimary::SchemaMigration Create (0.4ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181015143737"]]
|
110847
|
+
[1m[35m (1.4ms)[0m [1m[35mCOMMIT[0m
|
110848
|
+
Migrating to AddFileDataToModel (20181031190647)
|
110849
|
+
[1m[35m (0.3ms)[0m [1m[35mBEGIN[0m
|
110850
|
+
[1m[35m (0.4ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "file_data" jsonb[0m
|
110851
|
+
[1m[36mprimary::SchemaMigration Create (0.4ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181031190647"]]
|
110852
|
+
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
110853
|
+
Migrating to CreateKitheDerivatives (20181128185658)
|
110854
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
110855
|
+
[1m[35m (8.1ms)[0m [1m[35mCREATE TABLE "kithe_derivatives" ("id" bigserial primary key, "key" character varying NOT NULL, "file_data" jsonb, "asset_id" uuid NOT NULL, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL, CONSTRAINT "fk_rails_3dac8b4201"
|
110856
|
+
FOREIGN KEY ("asset_id")
|
110857
|
+
REFERENCES "kithe_models" ("id")
|
110858
|
+
)[0m
|
110859
|
+
[1m[35m (1.3ms)[0m [1m[35mCREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")[0m
|
110860
|
+
[1m[35m (1.4ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")[0m
|
110861
|
+
[1m[36mprimary::SchemaMigration Create (0.3ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181128185658"]]
|
110862
|
+
[1m[35m (0.5ms)[0m [1m[35mCOMMIT[0m
|
110863
|
+
Migrating to AddRepresentativeRelations (20190103144947)
|
110864
|
+
[1m[35m (6.4ms)[0m [1m[35mBEGIN[0m
|
110865
|
+
[1m[35m (0.5ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "representative_id" uuid[0m
|
110866
|
+
[1m[35m (7.5ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")[0m
|
110867
|
+
[1m[35m (1.6ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
|
110868
|
+
FOREIGN KEY ("representative_id")
|
110869
|
+
REFERENCES "kithe_models" ("id")
|
110870
|
+
[0m
|
110871
|
+
[1m[35m (0.4ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "leaf_representative_id" uuid[0m
|
110872
|
+
[1m[35m (1.3ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")[0m
|
110873
|
+
[1m[35m (1.6ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
|
110874
|
+
FOREIGN KEY ("leaf_representative_id")
|
110875
|
+
REFERENCES "kithe_models" ("id")
|
110876
|
+
[0m
|
110877
|
+
[1m[36mprimary::SchemaMigration Create (0.5ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20190103144947"]]
|
110878
|
+
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
110879
|
+
Migrating to ContainsAssociation (20190109192252)
|
110880
|
+
[1m[35m (0.3ms)[0m [1m[35mBEGIN[0m
|
110881
|
+
[1m[35m (2.2ms)[0m [1m[35mCREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid, CONSTRAINT "fk_rails_490c1158f7"
|
110882
|
+
FOREIGN KEY ("containee_id")
|
110883
|
+
REFERENCES "kithe_models" ("id")
|
110884
|
+
, CONSTRAINT "fk_rails_091010187b"
|
110885
|
+
FOREIGN KEY ("container_id")
|
110886
|
+
REFERENCES "kithe_models" ("id")
|
110887
|
+
)[0m
|
110888
|
+
[1m[35m (1.7ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")[0m
|
110889
|
+
[1m[35m (1.6ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")[0m
|
110890
|
+
[1m[36mprimary::SchemaMigration Create (0.4ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20190109192252"]]
|
110891
|
+
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
110892
|
+
Migrating to KitheModelType (20190404144551)
|
110893
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
110894
|
+
[1m[35m (0.4ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "kithe_model_type" integer[0m
|
110895
|
+
[1m[35m (0.5ms)[0m [1m[34mSELECT "kithe_models"."id" FROM "kithe_models" ORDER BY "kithe_models"."id" ASC LIMIT $1[0m [["LIMIT", 1000]]
|
110896
|
+
[1m[35m (0.6ms)[0m [1m[35mALTER TABLE "kithe_models" ALTER COLUMN "kithe_model_type" TYPE integer, ALTER COLUMN "kithe_model_type" SET NOT NULL[0m
|
110897
|
+
[1m[36mprimary::SchemaMigration Create (0.4ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20190404144551"]]
|
110898
|
+
[1m[35m (0.5ms)[0m [1m[35mCOMMIT[0m
|
110899
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.4ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
110900
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
110901
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.6ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"[0m [["key", "environment"], ["value", "development"], ["created_at", "2020-05-27 16:19:01.957849"], ["updated_at", "2020-05-27 16:19:01.957849"]]
|
110902
|
+
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
110903
|
+
[1m[35m (0.7ms)[0m [1m[34mSELECT pg_advisory_unlock(1601470156486188030)[0m
|
110904
|
+
[1m[35m (2.7ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110905
|
+
[1m[35m (5.0ms)[0m [1m[34m SELECT
|
110906
|
+
pp.proname AS name,
|
110907
|
+
pg_get_functiondef(pp.oid) AS definition
|
110908
|
+
FROM pg_proc pp
|
110909
|
+
JOIN pg_namespace pn
|
110910
|
+
ON pn.oid = pp.pronamespace
|
110911
|
+
LEFT JOIN pg_depend pd
|
110912
|
+
ON pd.objid = pp.oid AND pd.deptype = 'e'
|
110913
|
+
WHERE pn.nspname = 'public' AND pd.objid IS NULL
|
110914
|
+
ORDER BY pp.oid;
|
110915
|
+
[0m
|
110916
|
+
[1m[35m (1.8ms)[0m [1m[34m SELECT
|
110917
|
+
pt.tgname AS name,
|
110918
|
+
pg_get_triggerdef(pt.oid) AS definition
|
110919
|
+
FROM pg_trigger pt
|
110920
|
+
JOIN pg_class pc
|
110921
|
+
ON (pc.oid = pt.tgrelid)
|
110922
|
+
JOIN pg_proc pp
|
110923
|
+
ON (pp.oid = pt.tgfoid)
|
110924
|
+
WHERE pt.tgname
|
110925
|
+
NOT ILIKE '%constraint%' AND pt.tgname NOT ILIKE 'pg%'
|
110926
|
+
ORDER BY pc.oid;
|
110927
|
+
[0m
|
110928
|
+
[1m[35m (1.0ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110929
|
+
[1m[35m (0.5ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
110930
|
+
[1m[35m (0.4ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110931
|
+
[1m[35m (0.5ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
110932
|
+
[1m[35m (0.4ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110933
|
+
[1m[35m (0.4ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
110934
|
+
[1m[35m (209.2ms)[0m [1m[35mDROP DATABASE IF EXISTS "kithe_development"[0m
|
110935
|
+
[1m[35m (206.0ms)[0m [1m[35mDROP DATABASE IF EXISTS "kithe_test"[0m
|
110936
|
+
[1m[35m (512.2ms)[0m [1m[35mCREATE DATABASE "kithe_development" ENCODING = 'unicode'[0m
|
110937
|
+
[1m[35m (434.6ms)[0m [1m[35mCREATE DATABASE "kithe_test" ENCODING = 'unicode'[0m
|
110938
|
+
[1m[35m (7.1ms)[0m [1m[35mCREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)[0m
|
110939
|
+
[1m[35m (6.4ms)[0m [1m[35mCREATE 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)[0m
|
110940
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT pg_try_advisory_lock(1601470156486188030)[0m
|
110941
|
+
[1m[35m (0.7ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
110942
|
+
Migrating to EnablePgcryptoExtension (20181015143259)
|
110943
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
110944
|
+
[1m[35mSQL (17.0ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "pgcrypto"[0m
|
110945
|
+
[1m[36mprimary::SchemaMigration Create (0.6ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181015143259"]]
|
110946
|
+
[1m[35m (1.4ms)[0m [1m[35mCOMMIT[0m
|
110947
|
+
Migrating to CreateKitheModels (20181015143413)
|
110948
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
110949
|
+
[1m[35m (4.7ms)[0m [1m[35mCREATE 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)[0m
|
110950
|
+
[1m[35m (0.6ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "parent_id" uuid[0m
|
110951
|
+
[1m[35m (16.7ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")[0m
|
110952
|
+
[1m[35m (7.1ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
|
110953
|
+
FOREIGN KEY ("parent_id")
|
110954
|
+
REFERENCES "kithe_models" ("id")
|
110955
|
+
[0m
|
110956
|
+
[1m[36mprimary::SchemaMigration Create (82.0ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181015143413"]]
|
110957
|
+
[1m[35m (6.1ms)[0m [1m[35mCOMMIT[0m
|
110958
|
+
Migrating to KitheModelsFriendlierId (20181015143737)
|
110959
|
+
[1m[35m (0.3ms)[0m [1m[35mBEGIN[0m
|
110960
|
+
[1m[35m (2.7ms)[0m [1m[35mCREATE OR REPLACE FUNCTION kithe_models_friendlier_id_gen(min_value bigint, max_value bigint) RETURNS text AS $$
|
110961
|
+
DECLARE
|
110962
|
+
new_id_int bigint;
|
110963
|
+
new_id_str character varying := '';
|
110964
|
+
done bool;
|
110965
|
+
tries integer;
|
110966
|
+
alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
|
110967
|
+
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
110968
|
+
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
|
110969
|
+
alphabet_length integer := array_length(alphabet, 1);
|
110970
|
+
|
110971
|
+
BEGIN
|
110972
|
+
done := false;
|
110973
|
+
tries := 0;
|
110974
|
+
WHILE (NOT done) LOOP
|
110975
|
+
tries := tries + 1;
|
110976
|
+
IF (tries > 3) THEN
|
110977
|
+
RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
|
110978
|
+
END IF;
|
110979
|
+
|
110980
|
+
new_id_int := trunc(random() * (max_value - min_value) + min_value);
|
110981
|
+
|
110982
|
+
-- convert bigint to a Base-36 alphanumeric string
|
110983
|
+
-- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
|
110984
|
+
-- https://gist.github.com/btbytes/7159902
|
110985
|
+
WHILE new_id_int != 0 LOOP
|
110986
|
+
new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
|
110987
|
+
new_id_int := new_id_int / alphabet_length;
|
110988
|
+
END LOOP;
|
110989
|
+
|
110990
|
+
done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
|
110991
|
+
END LOOP;
|
110992
|
+
RETURN new_id_str;
|
110993
|
+
END;
|
110994
|
+
$$ LANGUAGE plpgsql;
|
110995
|
+
[0m
|
110996
|
+
[1m[35m (16.0ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "friendlier_id" character varying DEFAULT kithe_models_friendlier_id_gen(2821109907456, 101559956668415) NOT NULL[0m
|
110997
|
+
[1m[35m (1.6ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")[0m
|
110998
|
+
[1m[36mprimary::SchemaMigration Create (1.3ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181015143737"]]
|
110999
|
+
[1m[35m (2.0ms)[0m [1m[35mCOMMIT[0m
|
111000
|
+
Migrating to AddFileDataToModel (20181031190647)
|
111001
|
+
[1m[35m (1.1ms)[0m [1m[35mBEGIN[0m
|
111002
|
+
[1m[35m (1.4ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "file_data" jsonb[0m
|
111003
|
+
[1m[36mprimary::SchemaMigration Create (0.6ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181031190647"]]
|
111004
|
+
[1m[35m (0.8ms)[0m [1m[35mCOMMIT[0m
|
111005
|
+
Migrating to CreateKitheDerivatives (20181128185658)
|
111006
|
+
[1m[35m (1.9ms)[0m [1m[35mBEGIN[0m
|
111007
|
+
[1m[35m (7.2ms)[0m [1m[35mCREATE TABLE "kithe_derivatives" ("id" bigserial primary key, "key" character varying NOT NULL, "file_data" jsonb, "asset_id" uuid NOT NULL, "created_at" timestamp NOT NULL, "updated_at" timestamp NOT NULL, CONSTRAINT "fk_rails_3dac8b4201"
|
111008
|
+
FOREIGN KEY ("asset_id")
|
111009
|
+
REFERENCES "kithe_models" ("id")
|
111010
|
+
)[0m
|
111011
|
+
[1m[35m (1.3ms)[0m [1m[35mCREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")[0m
|
111012
|
+
[1m[35m (1.1ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")[0m
|
111013
|
+
[1m[36mprimary::SchemaMigration Create (0.4ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20181128185658"]]
|
111014
|
+
[1m[35m (0.5ms)[0m [1m[35mCOMMIT[0m
|
111015
|
+
Migrating to AddRepresentativeRelations (20190103144947)
|
111016
|
+
[1m[35m (0.4ms)[0m [1m[35mBEGIN[0m
|
111017
|
+
[1m[35m (0.5ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "representative_id" uuid[0m
|
111018
|
+
[1m[35m (1.3ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")[0m
|
111019
|
+
[1m[35m (1.8ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
|
111020
|
+
FOREIGN KEY ("representative_id")
|
111021
|
+
REFERENCES "kithe_models" ("id")
|
111022
|
+
[0m
|
111023
|
+
[1m[35m (0.7ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "leaf_representative_id" uuid[0m
|
111024
|
+
[1m[35m (3.9ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")[0m
|
111025
|
+
[1m[35m (3.0ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
|
111026
|
+
FOREIGN KEY ("leaf_representative_id")
|
111027
|
+
REFERENCES "kithe_models" ("id")
|
111028
|
+
[0m
|
111029
|
+
[1m[36mprimary::SchemaMigration Create (0.4ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20190103144947"]]
|
111030
|
+
[1m[35m (0.5ms)[0m [1m[35mCOMMIT[0m
|
111031
|
+
Migrating to ContainsAssociation (20190109192252)
|
111032
|
+
[1m[35m (0.3ms)[0m [1m[35mBEGIN[0m
|
111033
|
+
[1m[35m (2.0ms)[0m [1m[35mCREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid, CONSTRAINT "fk_rails_490c1158f7"
|
111034
|
+
FOREIGN KEY ("containee_id")
|
111035
|
+
REFERENCES "kithe_models" ("id")
|
111036
|
+
, CONSTRAINT "fk_rails_091010187b"
|
111037
|
+
FOREIGN KEY ("container_id")
|
111038
|
+
REFERENCES "kithe_models" ("id")
|
111039
|
+
)[0m
|
111040
|
+
[1m[35m (2.0ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")[0m
|
111041
|
+
[1m[35m (1.0ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")[0m
|
111042
|
+
[1m[36mprimary::SchemaMigration Create (0.4ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20190109192252"]]
|
111043
|
+
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
111044
|
+
Migrating to KitheModelType (20190404144551)
|
111045
|
+
[1m[35m (0.3ms)[0m [1m[35mBEGIN[0m
|
111046
|
+
[1m[35m (0.5ms)[0m [1m[35mALTER TABLE "kithe_models" ADD "kithe_model_type" integer[0m
|
111047
|
+
[1m[35m (1.3ms)[0m [1m[34mSELECT "kithe_models"."id" FROM "kithe_models" ORDER BY "kithe_models"."id" ASC LIMIT $1[0m [["LIMIT", 1000]]
|
111048
|
+
[1m[35m (0.9ms)[0m [1m[35mALTER TABLE "kithe_models" ALTER COLUMN "kithe_model_type" TYPE integer, ALTER COLUMN "kithe_model_type" SET NOT NULL[0m
|
111049
|
+
[1m[36mprimary::SchemaMigration Create (0.4ms)[0m [1m[32mINSERT INTO "schema_migrations" ("version") VALUES ($1) RETURNING "version"[0m [["version", "20190404144551"]]
|
111050
|
+
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
111051
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.6ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
111052
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
111053
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.7ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"[0m [["key", "environment"], ["value", "development"], ["created_at", "2020-05-27 16:19:20.045824"], ["updated_at", "2020-05-27 16:19:20.045824"]]
|
111054
|
+
[1m[35m (0.8ms)[0m [1m[35mCOMMIT[0m
|
111055
|
+
[1m[35m (0.5ms)[0m [1m[34mSELECT pg_advisory_unlock(1601470156486188030)[0m
|
111056
|
+
[1m[35m (1.3ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
111057
|
+
[1m[35m (5.0ms)[0m [1m[34m SELECT
|
111058
|
+
pp.proname AS name,
|
111059
|
+
pg_get_functiondef(pp.oid) AS definition
|
111060
|
+
FROM pg_proc pp
|
111061
|
+
JOIN pg_namespace pn
|
111062
|
+
ON pn.oid = pp.pronamespace
|
111063
|
+
LEFT JOIN pg_depend pd
|
111064
|
+
ON pd.objid = pp.oid AND pd.deptype = 'e'
|
111065
|
+
WHERE pn.nspname = 'public' AND pd.objid IS NULL
|
111066
|
+
ORDER BY pp.oid;
|
111067
|
+
[0m
|
111068
|
+
[1m[35m (1.9ms)[0m [1m[34m SELECT
|
111069
|
+
pt.tgname AS name,
|
111070
|
+
pg_get_triggerdef(pt.oid) AS definition
|
111071
|
+
FROM pg_trigger pt
|
111072
|
+
JOIN pg_class pc
|
111073
|
+
ON (pc.oid = pt.tgrelid)
|
111074
|
+
JOIN pg_proc pp
|
111075
|
+
ON (pp.oid = pt.tgfoid)
|
111076
|
+
WHERE pt.tgname
|
111077
|
+
NOT ILIKE '%constraint%' AND pt.tgname NOT ILIKE 'pg%'
|
111078
|
+
ORDER BY pc.oid;
|
111079
|
+
[0m
|
111080
|
+
[1m[35m (18.3ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
111081
|
+
[1m[35m (0.5ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
111082
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
111083
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
111084
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
111085
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
111086
|
+
[1m[35m (215.3ms)[0m [1m[35mDROP DATABASE IF EXISTS "kithe_development"[0m
|
111087
|
+
[1m[35m (375.5ms)[0m [1m[35mDROP DATABASE IF EXISTS "kithe_test"[0m
|
111088
|
+
[1m[35m (458.1ms)[0m [1m[35mCREATE DATABASE "kithe_development" ENCODING = 'unicode'[0m
|
111089
|
+
[1m[35m (933.1ms)[0m [1m[35mCREATE DATABASE "kithe_test" ENCODING = 'unicode'[0m
|
111090
|
+
[1m[35mSQL (12.8ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "pgcrypto"[0m
|
111091
|
+
[1m[35mSQL (0.5ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "plpgsql"[0m
|
111092
|
+
[1m[35m (2.4ms)[0m [1m[35mCREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint)
|
111093
|
+
RETURNS text
|
111094
|
+
LANGUAGE plpgsql
|
111095
|
+
AS $function$
|
111096
|
+
DECLARE
|
111097
|
+
new_id_int bigint;
|
111098
|
+
new_id_str character varying := '';
|
111099
|
+
done bool;
|
111100
|
+
tries integer;
|
111101
|
+
alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
|
111102
|
+
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
111103
|
+
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
|
111104
|
+
alphabet_length integer := array_length(alphabet, 1);
|
111105
|
+
|
111106
|
+
BEGIN
|
111107
|
+
done := false;
|
111108
|
+
tries := 0;
|
111109
|
+
WHILE (NOT done) LOOP
|
111110
|
+
tries := tries + 1;
|
111111
|
+
IF (tries > 3) THEN
|
111112
|
+
RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
|
111113
|
+
END IF;
|
111114
|
+
|
111115
|
+
new_id_int := trunc(random() * (max_value - min_value) + min_value);
|
111116
|
+
|
111117
|
+
-- convert bigint to a Base-36 alphanumeric string
|
111118
|
+
-- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
|
111119
|
+
-- https://gist.github.com/btbytes/7159902
|
111120
|
+
WHILE new_id_int != 0 LOOP
|
111121
|
+
new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
|
111122
|
+
new_id_int := new_id_int / alphabet_length;
|
111123
|
+
END LOOP;
|
111124
|
+
|
111125
|
+
done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
|
111126
|
+
END LOOP;
|
111127
|
+
RETURN new_id_str;
|
111128
|
+
END;
|
111129
|
+
$function$
|
111130
|
+
[0m
|
111131
|
+
[1m[35m (0.3ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_derivatives" CASCADE[0m
|
111132
|
+
[1m[35m (6.7ms)[0m [1m[35mCREATE 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)[0m
|
111133
|
+
[1m[35m (1.9ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")[0m
|
111134
|
+
[1m[35m (1.4ms)[0m [1m[35mCREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")[0m
|
111135
|
+
[1m[35m (0.2ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_model_contains" CASCADE[0m
|
111136
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid)[0m
|
111137
|
+
[1m[35m (1.5ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")[0m
|
111138
|
+
[1m[35m (2.5ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")[0m
|
111139
|
+
[1m[35m (0.5ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_models" CASCADE[0m
|
111140
|
+
[1m[35m (7.8ms)[0m [1m[35mCREATE 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)[0m
|
111141
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")[0m
|
111142
|
+
[1m[35m (23.6ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")[0m
|
111143
|
+
[1m[35m (8.3ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")[0m
|
111144
|
+
[1m[35m (1.6ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")[0m
|
111145
|
+
[1m[35m (3.6ms)[0m [1m[35mALTER TABLE "kithe_derivatives" ADD CONSTRAINT "fk_rails_3dac8b4201"
|
111146
|
+
FOREIGN KEY ("asset_id")
|
111147
|
+
REFERENCES "kithe_models" ("id")
|
111148
|
+
[0m
|
111149
|
+
[1m[35m (1.9ms)[0m [1m[35mALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_490c1158f7"
|
111150
|
+
FOREIGN KEY ("containee_id")
|
111151
|
+
REFERENCES "kithe_models" ("id")
|
111152
|
+
[0m
|
111153
|
+
[1m[35m (2.0ms)[0m [1m[35mALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_091010187b"
|
111154
|
+
FOREIGN KEY ("container_id")
|
111155
|
+
REFERENCES "kithe_models" ("id")
|
111156
|
+
[0m
|
111157
|
+
[1m[35m (1.9ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
|
111158
|
+
FOREIGN KEY ("leaf_representative_id")
|
111159
|
+
REFERENCES "kithe_models" ("id")
|
111160
|
+
[0m
|
111161
|
+
[1m[35m (2.0ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
|
111162
|
+
FOREIGN KEY ("parent_id")
|
111163
|
+
REFERENCES "kithe_models" ("id")
|
111164
|
+
[0m
|
111165
|
+
[1m[35m (2.1ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
|
111166
|
+
FOREIGN KEY ("representative_id")
|
111167
|
+
REFERENCES "kithe_models" ("id")
|
111168
|
+
[0m
|
111169
|
+
[1m[35m (3.4ms)[0m [1m[35mCREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)[0m
|
111170
|
+
[1m[35m (0.8ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
111171
|
+
[1m[35m (1.0ms)[0m [1m[32mINSERT INTO "schema_migrations" (version) VALUES (20190404144551)[0m
|
111172
|
+
[1m[35m (10.3ms)[0m [1m[32mINSERT INTO "schema_migrations" (version) VALUES
|
111173
|
+
(20181015143259),
|
111174
|
+
(20181015143413),
|
111175
|
+
(20181015143737),
|
111176
|
+
(20181031190647),
|
111177
|
+
(20181128185658),
|
111178
|
+
(20190103144947),
|
111179
|
+
(20190109192252);
|
111180
|
+
|
111181
|
+
[0m
|
111182
|
+
[1m[35m (13.4ms)[0m [1m[35mCREATE 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)[0m
|
111183
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.5ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
111184
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
111185
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.6ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"[0m [["key", "environment"], ["value", "development"], ["created_at", "2020-05-27 16:19:32.359365"], ["updated_at", "2020-05-27 16:19:32.359365"]]
|
111186
|
+
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
111187
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.4ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
111188
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.4ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "schema_sha1"], ["LIMIT", 1]]
|
111189
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
111190
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.8ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"[0m [["key", "schema_sha1"], ["value", "42c53de0cd440a8a7ed21435cee78257b6e0c991"], ["created_at", "2020-05-27 16:19:32.368638"], ["updated_at", "2020-05-27 16:19:32.368638"]]
|
111191
|
+
[1m[35m (0.6ms)[0m [1m[35mCOMMIT[0m
|
111192
|
+
[1m[35mSQL (19.4ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "pgcrypto"[0m
|
111193
|
+
[1m[35mSQL (0.2ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "plpgsql"[0m
|
111194
|
+
[1m[35m (2.5ms)[0m [1m[35mCREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint)
|
111195
|
+
RETURNS text
|
111196
|
+
LANGUAGE plpgsql
|
111197
|
+
AS $function$
|
111198
|
+
DECLARE
|
111199
|
+
new_id_int bigint;
|
111200
|
+
new_id_str character varying := '';
|
111201
|
+
done bool;
|
111202
|
+
tries integer;
|
111203
|
+
alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
|
111204
|
+
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
111205
|
+
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
|
111206
|
+
alphabet_length integer := array_length(alphabet, 1);
|
111207
|
+
|
111208
|
+
BEGIN
|
111209
|
+
done := false;
|
111210
|
+
tries := 0;
|
111211
|
+
WHILE (NOT done) LOOP
|
111212
|
+
tries := tries + 1;
|
111213
|
+
IF (tries > 3) THEN
|
111214
|
+
RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
|
111215
|
+
END IF;
|
111216
|
+
|
111217
|
+
new_id_int := trunc(random() * (max_value - min_value) + min_value);
|
111218
|
+
|
111219
|
+
-- convert bigint to a Base-36 alphanumeric string
|
111220
|
+
-- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
|
111221
|
+
-- https://gist.github.com/btbytes/7159902
|
111222
|
+
WHILE new_id_int != 0 LOOP
|
111223
|
+
new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
|
111224
|
+
new_id_int := new_id_int / alphabet_length;
|
111225
|
+
END LOOP;
|
111226
|
+
|
111227
|
+
done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
|
111228
|
+
END LOOP;
|
111229
|
+
RETURN new_id_str;
|
111230
|
+
END;
|
111231
|
+
$function$
|
111232
|
+
[0m
|
111233
|
+
[1m[35m (0.3ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_derivatives" CASCADE[0m
|
111234
|
+
[1m[35m (15.3ms)[0m [1m[35mCREATE 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)[0m
|
111235
|
+
[1m[35m (4.1ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")[0m
|
111236
|
+
[1m[35m (2.7ms)[0m [1m[35mCREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")[0m
|
111237
|
+
[1m[35m (0.4ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_model_contains" CASCADE[0m
|
111238
|
+
[1m[35m (3.2ms)[0m [1m[35mCREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid)[0m
|
111239
|
+
[1m[35m (2.3ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")[0m
|
111240
|
+
[1m[35m (1.3ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")[0m
|
111241
|
+
[1m[35m (0.2ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_models" CASCADE[0m
|
111242
|
+
[1m[35m (3.7ms)[0m [1m[35mCREATE 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)[0m
|
111243
|
+
[1m[35m (1.6ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")[0m
|
111244
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")[0m
|
111245
|
+
[1m[35m (2.2ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")[0m
|
111246
|
+
[1m[35m (2.3ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")[0m
|
111247
|
+
[1m[35m (5.0ms)[0m [1m[35mALTER TABLE "kithe_derivatives" ADD CONSTRAINT "fk_rails_3dac8b4201"
|
111248
|
+
FOREIGN KEY ("asset_id")
|
111249
|
+
REFERENCES "kithe_models" ("id")
|
111250
|
+
[0m
|
111251
|
+
[1m[35m (2.2ms)[0m [1m[35mALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_490c1158f7"
|
111252
|
+
FOREIGN KEY ("containee_id")
|
111253
|
+
REFERENCES "kithe_models" ("id")
|
111254
|
+
[0m
|
111255
|
+
[1m[35m (45.4ms)[0m [1m[35mALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_091010187b"
|
111256
|
+
FOREIGN KEY ("container_id")
|
111257
|
+
REFERENCES "kithe_models" ("id")
|
111258
|
+
[0m
|
111259
|
+
[1m[35m (1.8ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
|
111260
|
+
FOREIGN KEY ("leaf_representative_id")
|
111261
|
+
REFERENCES "kithe_models" ("id")
|
111262
|
+
[0m
|
111263
|
+
[1m[35m (2.3ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
|
111264
|
+
FOREIGN KEY ("parent_id")
|
111265
|
+
REFERENCES "kithe_models" ("id")
|
111266
|
+
[0m
|
111267
|
+
[1m[35m (9.7ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
|
111268
|
+
FOREIGN KEY ("representative_id")
|
111269
|
+
REFERENCES "kithe_models" ("id")
|
111270
|
+
[0m
|
111271
|
+
[1m[35m (5.2ms)[0m [1m[35mCREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)[0m
|
111272
|
+
[1m[35m (1.0ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
111273
|
+
[1m[35m (3.2ms)[0m [1m[32mINSERT INTO "schema_migrations" (version) VALUES (20190404144551)[0m
|
111274
|
+
[1m[35m (4.5ms)[0m [1m[32mINSERT INTO "schema_migrations" (version) VALUES
|
111275
|
+
(20181015143259),
|
111276
|
+
(20181015143413),
|
111277
|
+
(20181015143737),
|
111278
|
+
(20181031190647),
|
111279
|
+
(20181128185658),
|
111280
|
+
(20190103144947),
|
111281
|
+
(20190109192252);
|
111282
|
+
|
111283
|
+
[0m
|
111284
|
+
[1m[35m (42.4ms)[0m [1m[35mCREATE 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)[0m
|
111285
|
+
[1m[36mActiveRecord::InternalMetadata Load (2.1ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
111286
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
111287
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.7ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"[0m [["key", "environment"], ["value", "development"], ["created_at", "2020-05-27 16:19:32.703724"], ["updated_at", "2020-05-27 16:19:32.703724"]]
|
111288
|
+
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
111289
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.4ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
111290
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
111291
|
+
[1m[36mActiveRecord::InternalMetadata Update (0.5ms)[0m [1m[33mUPDATE "ar_internal_metadata" SET "value" = $1, "updated_at" = $2 WHERE "ar_internal_metadata"."key" = $3[0m [["value", "test"], ["updated_at", "2020-05-27 16:19:32.711074"], ["key", "environment"]]
|
111292
|
+
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
111293
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.3ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "schema_sha1"], ["LIMIT", 1]]
|
111294
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
111295
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.6ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"[0m [["key", "schema_sha1"], ["value", "42c53de0cd440a8a7ed21435cee78257b6e0c991"], ["created_at", "2020-05-27 16:19:32.718252"], ["updated_at", "2020-05-27 16:19:32.718252"]]
|
111296
|
+
[1m[35m (0.7ms)[0m [1m[35mCOMMIT[0m
|
111297
|
+
[1m[35m (16.6ms)[0m [1m[34mSELECT pg_try_advisory_lock(1601470156486188030)[0m
|
111298
|
+
[1m[35m (2.4ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
111299
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.6ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
111300
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT pg_advisory_unlock(1601470156486188030)[0m
|
111301
|
+
[1m[35m (0.9ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
111302
|
+
[1m[35m (66.1ms)[0m [1m[34m SELECT
|
111303
|
+
pp.proname AS name,
|
111304
|
+
pg_get_functiondef(pp.oid) AS definition
|
111305
|
+
FROM pg_proc pp
|
111306
|
+
JOIN pg_namespace pn
|
111307
|
+
ON pn.oid = pp.pronamespace
|
111308
|
+
LEFT JOIN pg_depend pd
|
111309
|
+
ON pd.objid = pp.oid AND pd.deptype = 'e'
|
111310
|
+
WHERE pn.nspname = 'public' AND pd.objid IS NULL
|
111311
|
+
ORDER BY pp.oid;
|
111312
|
+
[0m
|
111313
|
+
[1m[35m (2.0ms)[0m [1m[34m SELECT
|
111314
|
+
pt.tgname AS name,
|
111315
|
+
pg_get_triggerdef(pt.oid) AS definition
|
111316
|
+
FROM pg_trigger pt
|
111317
|
+
JOIN pg_class pc
|
111318
|
+
ON (pc.oid = pt.tgrelid)
|
111319
|
+
JOIN pg_proc pp
|
111320
|
+
ON (pp.oid = pt.tgfoid)
|
111321
|
+
WHERE pt.tgname
|
111322
|
+
NOT ILIKE '%constraint%' AND pt.tgname NOT ILIKE 'pg%'
|
111323
|
+
ORDER BY pc.oid;
|
111324
|
+
[0m
|
111325
|
+
[1m[35m (1.0ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
111326
|
+
[1m[35m (0.6ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
111327
|
+
[1m[35m (0.6ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
111328
|
+
[1m[35m (0.2ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
111329
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
111330
|
+
[1m[35m (0.3ms)[0m [1m[34mSELECT "ar_internal_metadata"."value" FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1[0m [["key", "environment"]]
|
111331
|
+
[1m[35m (239.7ms)[0m [1m[35mDROP DATABASE IF EXISTS "kithe_development"[0m
|
111332
|
+
[1m[35m (242.5ms)[0m [1m[35mDROP DATABASE IF EXISTS "kithe_test"[0m
|
111333
|
+
[1m[35m (905.5ms)[0m [1m[35mCREATE DATABASE "kithe_development" ENCODING = 'unicode'[0m
|
111334
|
+
[1m[35m (604.8ms)[0m [1m[35mCREATE DATABASE "kithe_test" ENCODING = 'unicode'[0m
|
111335
|
+
[1m[35mSQL (73.8ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "pgcrypto"[0m
|
111336
|
+
[1m[35mSQL (0.2ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "plpgsql"[0m
|
111337
|
+
[1m[35m (98.8ms)[0m [1m[35mCREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint)
|
111338
|
+
RETURNS text
|
111339
|
+
LANGUAGE plpgsql
|
111340
|
+
AS $function$
|
111341
|
+
DECLARE
|
111342
|
+
new_id_int bigint;
|
111343
|
+
new_id_str character varying := '';
|
111344
|
+
done bool;
|
111345
|
+
tries integer;
|
111346
|
+
alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
|
111347
|
+
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
111348
|
+
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
|
111349
|
+
alphabet_length integer := array_length(alphabet, 1);
|
111350
|
+
|
111351
|
+
BEGIN
|
111352
|
+
done := false;
|
111353
|
+
tries := 0;
|
111354
|
+
WHILE (NOT done) LOOP
|
111355
|
+
tries := tries + 1;
|
111356
|
+
IF (tries > 3) THEN
|
111357
|
+
RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
|
111358
|
+
END IF;
|
111359
|
+
|
111360
|
+
new_id_int := trunc(random() * (max_value - min_value) + min_value);
|
111361
|
+
|
111362
|
+
-- convert bigint to a Base-36 alphanumeric string
|
111363
|
+
-- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
|
111364
|
+
-- https://gist.github.com/btbytes/7159902
|
111365
|
+
WHILE new_id_int != 0 LOOP
|
111366
|
+
new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
|
111367
|
+
new_id_int := new_id_int / alphabet_length;
|
111368
|
+
END LOOP;
|
111369
|
+
|
111370
|
+
done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
|
111371
|
+
END LOOP;
|
111372
|
+
RETURN new_id_str;
|
111373
|
+
END;
|
111374
|
+
$function$
|
111375
|
+
[0m
|
111376
|
+
[1m[35m (5.8ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_derivatives" CASCADE[0m
|
111377
|
+
[1m[35m (23.5ms)[0m [1m[35mCREATE 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)[0m
|
111378
|
+
[1m[35m (2.7ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")[0m
|
111379
|
+
[1m[35m (2.7ms)[0m [1m[35mCREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")[0m
|
111380
|
+
[1m[35m (0.4ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_model_contains" CASCADE[0m
|
111381
|
+
[1m[35m (2.9ms)[0m [1m[35mCREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid)[0m
|
111382
|
+
[1m[35m (1.6ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")[0m
|
111383
|
+
[1m[35m (3.0ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")[0m
|
111384
|
+
[1m[35m (0.2ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_models" CASCADE[0m
|
111385
|
+
[1m[35m (5.1ms)[0m [1m[35mCREATE 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)[0m
|
111386
|
+
[1m[35m (1.5ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")[0m
|
111387
|
+
[1m[35m (1.5ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")[0m
|
111388
|
+
[1m[35m (1.3ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")[0m
|
111389
|
+
[1m[35m (1.2ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")[0m
|
111390
|
+
[1m[35m (7.8ms)[0m [1m[35mALTER TABLE "kithe_derivatives" ADD CONSTRAINT "fk_rails_3dac8b4201"
|
111391
|
+
FOREIGN KEY ("asset_id")
|
111392
|
+
REFERENCES "kithe_models" ("id")
|
111393
|
+
[0m
|
111394
|
+
[1m[35m (1.8ms)[0m [1m[35mALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_490c1158f7"
|
111395
|
+
FOREIGN KEY ("containee_id")
|
111396
|
+
REFERENCES "kithe_models" ("id")
|
111397
|
+
[0m
|
111398
|
+
[1m[35m (1.8ms)[0m [1m[35mALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_091010187b"
|
111399
|
+
FOREIGN KEY ("container_id")
|
111400
|
+
REFERENCES "kithe_models" ("id")
|
111401
|
+
[0m
|
111402
|
+
[1m[35m (2.4ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
|
111403
|
+
FOREIGN KEY ("leaf_representative_id")
|
111404
|
+
REFERENCES "kithe_models" ("id")
|
111405
|
+
[0m
|
111406
|
+
[1m[35m (1.7ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
|
111407
|
+
FOREIGN KEY ("parent_id")
|
111408
|
+
REFERENCES "kithe_models" ("id")
|
111409
|
+
[0m
|
111410
|
+
[1m[35m (1.9ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
|
111411
|
+
FOREIGN KEY ("representative_id")
|
111412
|
+
REFERENCES "kithe_models" ("id")
|
111413
|
+
[0m
|
111414
|
+
[1m[35m (3.5ms)[0m [1m[35mCREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)[0m
|
111415
|
+
[1m[35m (0.7ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
111416
|
+
[1m[35m (0.7ms)[0m [1m[32mINSERT INTO "schema_migrations" (version) VALUES (20190404144551)[0m
|
111417
|
+
[1m[35m (0.8ms)[0m [1m[32mINSERT INTO "schema_migrations" (version) VALUES
|
111418
|
+
(20181015143259),
|
111419
|
+
(20181015143413),
|
111420
|
+
(20181015143737),
|
111421
|
+
(20181031190647),
|
111422
|
+
(20181128185658),
|
111423
|
+
(20190103144947),
|
111424
|
+
(20190109192252);
|
111425
|
+
|
111426
|
+
[0m
|
111427
|
+
[1m[35m (3.6ms)[0m [1m[35mCREATE 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)[0m
|
111428
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.5ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
111429
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
111430
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.5ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"[0m [["key", "environment"], ["value", "development"], ["created_at", "2020-05-28 13:26:55.432158"], ["updated_at", "2020-05-28 13:26:55.432158"]]
|
111431
|
+
[1m[35m (0.5ms)[0m [1m[35mCOMMIT[0m
|
111432
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.4ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
111433
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.4ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "schema_sha1"], ["LIMIT", 1]]
|
111434
|
+
[1m[35m (0.1ms)[0m [1m[35mBEGIN[0m
|
111435
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.4ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"[0m [["key", "schema_sha1"], ["value", "0e24e2caa948e64f3be11233d707b8abffa0f356"], ["created_at", "2020-05-28 13:26:55.460004"], ["updated_at", "2020-05-28 13:26:55.460004"]]
|
111436
|
+
[1m[35m (0.4ms)[0m [1m[35mCOMMIT[0m
|
111437
|
+
[1m[35mSQL (16.2ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "pgcrypto"[0m
|
111438
|
+
[1m[35mSQL (0.3ms)[0m [1m[35mCREATE EXTENSION IF NOT EXISTS "plpgsql"[0m
|
111439
|
+
[1m[35m (2.3ms)[0m [1m[35mCREATE OR REPLACE FUNCTION public.kithe_models_friendlier_id_gen(min_value bigint, max_value bigint)
|
111440
|
+
RETURNS text
|
111441
|
+
LANGUAGE plpgsql
|
111442
|
+
AS $function$
|
111443
|
+
DECLARE
|
111444
|
+
new_id_int bigint;
|
111445
|
+
new_id_str character varying := '';
|
111446
|
+
done bool;
|
111447
|
+
tries integer;
|
111448
|
+
alphabet char[] := ARRAY['0','1','2','3','4','5','6','7','8','9',
|
111449
|
+
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
111450
|
+
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'];
|
111451
|
+
alphabet_length integer := array_length(alphabet, 1);
|
111452
|
+
|
111453
|
+
BEGIN
|
111454
|
+
done := false;
|
111455
|
+
tries := 0;
|
111456
|
+
WHILE (NOT done) LOOP
|
111457
|
+
tries := tries + 1;
|
111458
|
+
IF (tries > 3) THEN
|
111459
|
+
RAISE 'Could not find non-conflicting friendlier_id in 3 tries';
|
111460
|
+
END IF;
|
111461
|
+
|
111462
|
+
new_id_int := trunc(random() * (max_value - min_value) + min_value);
|
111463
|
+
|
111464
|
+
-- convert bigint to a Base-36 alphanumeric string
|
111465
|
+
-- see https://web.archive.org/web/20130420084605/http://www.jamiebegin.com/base36-conversion-in-postgresql/
|
111466
|
+
-- https://gist.github.com/btbytes/7159902
|
111467
|
+
WHILE new_id_int != 0 LOOP
|
111468
|
+
new_id_str := alphabet[(new_id_int % alphabet_length)+1] || new_id_str;
|
111469
|
+
new_id_int := new_id_int / alphabet_length;
|
111470
|
+
END LOOP;
|
111471
|
+
|
111472
|
+
done := NOT exists(SELECT 1 FROM kithe_models WHERE friendlier_id=new_id_str);
|
111473
|
+
END LOOP;
|
111474
|
+
RETURN new_id_str;
|
111475
|
+
END;
|
111476
|
+
$function$
|
111477
|
+
[0m
|
111478
|
+
[1m[35m (0.2ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_derivatives" CASCADE[0m
|
111479
|
+
[1m[35m (6.7ms)[0m [1m[35mCREATE 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)[0m
|
111480
|
+
[1m[35m (2.2ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_derivatives_on_asset_id_and_key" ON "kithe_derivatives" ("asset_id", "key")[0m
|
111481
|
+
[1m[35m (1.8ms)[0m [1m[35mCREATE INDEX "index_kithe_derivatives_on_asset_id" ON "kithe_derivatives" ("asset_id")[0m
|
111482
|
+
[1m[35m (0.2ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_model_contains" CASCADE[0m
|
111483
|
+
[1m[35m (1.6ms)[0m [1m[35mCREATE TABLE "kithe_model_contains" ("containee_id" uuid, "container_id" uuid)[0m
|
111484
|
+
[1m[35m (1.9ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_containee_id" ON "kithe_model_contains" ("containee_id")[0m
|
111485
|
+
[1m[35m (1.5ms)[0m [1m[35mCREATE INDEX "index_kithe_model_contains_on_container_id" ON "kithe_model_contains" ("container_id")[0m
|
111486
|
+
[1m[35m (0.2ms)[0m [1m[35mDROP TABLE IF EXISTS "kithe_models" CASCADE[0m
|
111487
|
+
[1m[35m (3.9ms)[0m [1m[35mCREATE 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)[0m
|
111488
|
+
[1m[35m (1.3ms)[0m [1m[35mCREATE UNIQUE INDEX "index_kithe_models_on_friendlier_id" ON "kithe_models" ("friendlier_id")[0m
|
111489
|
+
[1m[35m (1.3ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_leaf_representative_id" ON "kithe_models" ("leaf_representative_id")[0m
|
111490
|
+
[1m[35m (12.7ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_parent_id" ON "kithe_models" ("parent_id")[0m
|
111491
|
+
[1m[35m (12.3ms)[0m [1m[35mCREATE INDEX "index_kithe_models_on_representative_id" ON "kithe_models" ("representative_id")[0m
|
111492
|
+
[1m[35m (5.1ms)[0m [1m[35mALTER TABLE "kithe_derivatives" ADD CONSTRAINT "fk_rails_3dac8b4201"
|
111493
|
+
FOREIGN KEY ("asset_id")
|
111494
|
+
REFERENCES "kithe_models" ("id")
|
111495
|
+
[0m
|
111496
|
+
[1m[35m (2.0ms)[0m [1m[35mALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_490c1158f7"
|
111497
|
+
FOREIGN KEY ("containee_id")
|
111498
|
+
REFERENCES "kithe_models" ("id")
|
111499
|
+
[0m
|
111500
|
+
[1m[35m (1.9ms)[0m [1m[35mALTER TABLE "kithe_model_contains" ADD CONSTRAINT "fk_rails_091010187b"
|
111501
|
+
FOREIGN KEY ("container_id")
|
111502
|
+
REFERENCES "kithe_models" ("id")
|
111503
|
+
[0m
|
111504
|
+
[1m[35m (1.9ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_403cce5c0d"
|
111505
|
+
FOREIGN KEY ("leaf_representative_id")
|
111506
|
+
REFERENCES "kithe_models" ("id")
|
111507
|
+
[0m
|
111508
|
+
[1m[35m (1.8ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_90130a9780"
|
111509
|
+
FOREIGN KEY ("parent_id")
|
111510
|
+
REFERENCES "kithe_models" ("id")
|
111511
|
+
[0m
|
111512
|
+
[1m[35m (2.0ms)[0m [1m[35mALTER TABLE "kithe_models" ADD CONSTRAINT "fk_rails_afa93b7b5d"
|
111513
|
+
FOREIGN KEY ("representative_id")
|
111514
|
+
REFERENCES "kithe_models" ("id")
|
111515
|
+
[0m
|
111516
|
+
[1m[35m (3.7ms)[0m [1m[35mCREATE TABLE "schema_migrations" ("version" character varying NOT NULL PRIMARY KEY)[0m
|
111517
|
+
[1m[35m (0.7ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|
111518
|
+
[1m[35m (0.9ms)[0m [1m[32mINSERT INTO "schema_migrations" (version) VALUES (20190404144551)[0m
|
111519
|
+
[1m[35m (0.7ms)[0m [1m[32mINSERT INTO "schema_migrations" (version) VALUES
|
111520
|
+
(20181015143259),
|
111521
|
+
(20181015143413),
|
111522
|
+
(20181015143737),
|
111523
|
+
(20181031190647),
|
111524
|
+
(20181128185658),
|
111525
|
+
(20190103144947),
|
111526
|
+
(20190109192252);
|
111527
|
+
|
111528
|
+
[0m
|
111529
|
+
[1m[35m (3.3ms)[0m [1m[35mCREATE 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)[0m
|
111530
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.4ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
111531
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
111532
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.7ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"[0m [["key", "environment"], ["value", "development"], ["created_at", "2020-05-28 13:26:55.653588"], ["updated_at", "2020-05-28 13:26:55.653588"]]
|
111533
|
+
[1m[35m (0.7ms)[0m [1m[35mCOMMIT[0m
|
111534
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.3ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
|
111535
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
111536
|
+
[1m[36mActiveRecord::InternalMetadata Update (0.6ms)[0m [1m[33mUPDATE "ar_internal_metadata" SET "value" = $1, "updated_at" = $2 WHERE "ar_internal_metadata"."key" = $3[0m [["value", "test"], ["updated_at", "2020-05-28 13:26:55.661463"], ["key", "environment"]]
|
111537
|
+
[1m[35m (0.3ms)[0m [1m[35mCOMMIT[0m
|
111538
|
+
[1m[36mActiveRecord::InternalMetadata Load (0.3ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "schema_sha1"], ["LIMIT", 1]]
|
111539
|
+
[1m[35m (0.2ms)[0m [1m[35mBEGIN[0m
|
111540
|
+
[1m[36mActiveRecord::InternalMetadata Create (0.3ms)[0m [1m[32mINSERT INTO "ar_internal_metadata" ("key", "value", "created_at", "updated_at") VALUES ($1, $2, $3, $4) RETURNING "key"[0m [["key", "schema_sha1"], ["value", "0e24e2caa948e64f3be11233d707b8abffa0f356"], ["created_at", "2020-05-28 13:26:55.668516"], ["updated_at", "2020-05-28 13:26:55.668516"]]
|
111541
|
+
[1m[35m (0.5ms)[0m [1m[35mCOMMIT[0m
|
111542
|
+
[1m[35m (1.0ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
|