db_memoize 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/db_memoize/migrations.rb +23 -39
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 177375f46d8f0b2afe886da6c9930f1350a4533e29f29be32b12092b800ef0fc
|
4
|
+
data.tar.gz: 64fe8da3bdfe0623d0e397d432d9357f6ee9103c72514f49cd27456498702d51
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c46ffd65923aafb8bb614664a9f9d74633e651bd16b33c7a8aa95b7f9828c60101479e34b3dfb6b2c0a7986f4dfe80afd768fc7765c1d10823de5363911e64f0
|
7
|
+
data.tar.gz: 330ed93426b839ebc65f97ffc65fc92dc9a464a5c830ea3f179d64492f8102230e4970dd2ca599d5040d11e854437723f7b4da3a5b21f5527db2e49ebdf8db61
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.4
|
@@ -2,48 +2,32 @@ module DbMemoize
|
|
2
2
|
class Migrations
|
3
3
|
class << self
|
4
4
|
def create_tables(migration)
|
5
|
-
migration.
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
end
|
5
|
+
migration.execute <<~SQL
|
6
|
+
CREATE TABLE IF NOT EXISTS memoized_values (
|
7
|
+
entity_table_name varchar,
|
8
|
+
entity_id integer,
|
9
|
+
method_name varchar,
|
10
|
+
created_at timestamp without time zone
|
11
|
+
);
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
def migrate_empty_arguments_support(migration)
|
21
|
-
# entity_id/entity_table_name should have a better chance to be useful, since
|
22
|
-
# there is more variance in entity_ids than there is in entity_table_names.
|
23
|
-
migration.remove_index :memoized_values, [:entity_table_name, :entity_id]
|
24
|
-
migration.add_index :memoized_values, [:entity_id, :entity_table_name]
|
25
|
-
|
26
|
-
# add an index to be useful to look up entries where arguments_hash is NULL.
|
27
|
-
# (which is the case for plain attributes of an object)
|
28
|
-
migration.execute 'CREATE INDEX IF NOT EXISTS memoized_attributes_idx ON memoized_values((arguments_hash IS NULL))'
|
29
|
-
end
|
30
|
-
|
31
|
-
def drop_arguments_support(migration)
|
32
|
-
migration.execute 'DROP INDEX IF EXISTS memoized_attributes_idx'
|
33
|
-
migration.execute 'ALTER TABLE memoized_values DROP COLUMN IF EXISTS arguments_hash'
|
13
|
+
-- entity_id/entity_table_name should have a better chance to be useful, since
|
14
|
+
-- there is more variance in entity_ids than there is in entity_table_names.
|
15
|
+
DROP INDEX IF EXISTS index_memoized_values_on_entity_id_and_entity_table_name;
|
16
|
+
DROP INDEX IF EXISTS index_memoized_values_on_entity_table_name_and_entity_id;
|
17
|
+
CREATE UNIQUE INDEX IF NOT EXISTS memoized_attributes_idx2
|
18
|
+
ON memoized_values(entity_id, entity_table_name, method_name);
|
34
19
|
|
35
|
-
|
36
|
-
|
37
|
-
end
|
20
|
+
ALTER TABLE memoized_values DROP COLUMN IF EXISTS arguments_hash;
|
21
|
+
ALTER TABLE memoized_values DROP COLUMN IF EXISTS value;
|
38
22
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
23
|
+
ALTER TABLE memoized_values ADD COLUMN IF NOT EXISTS val_string varchar;
|
24
|
+
ALTER TABLE memoized_values ADD COLUMN IF NOT EXISTS val_integer bigint;
|
25
|
+
ALTER TABLE memoized_values ADD COLUMN IF NOT EXISTS val_float double precision;
|
26
|
+
ALTER TABLE memoized_values ADD COLUMN IF NOT EXISTS val_time timestamp without time zone;
|
27
|
+
ALTER TABLE memoized_values ADD COLUMN IF NOT EXISTS val_object jsonb;
|
28
|
+
ALTER TABLE memoized_values ADD COLUMN IF NOT EXISTS val_boolean boolean;
|
29
|
+
ALTER TABLE memoized_values ADD COLUMN IF NOT EXISTS val_nil boolean;
|
30
|
+
SQL
|
47
31
|
end
|
48
32
|
end
|
49
33
|
end
|