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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/db_memoize/migrations.rb +23 -39
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 97e72fcdd1dbd2a1db2cd3400748c47741e7d7cdcd43330b5a89e037d3593d2c
4
- data.tar.gz: 4b120a93fa9737ef693364c431e2e746ebb685a39f0d35df2ae265dddb7333ba
3
+ metadata.gz: 177375f46d8f0b2afe886da6c9930f1350a4533e29f29be32b12092b800ef0fc
4
+ data.tar.gz: 64fe8da3bdfe0623d0e397d432d9357f6ee9103c72514f49cd27456498702d51
5
5
  SHA512:
6
- metadata.gz: 33768ae587051b27f50b299bfb3405d94f192bd363f029f586e216fb65d6c5cd8005dd01fab890e50a99e0c726310816a54b99430d903082f7101cbd073ac151
7
- data.tar.gz: 63f31ab7710d3c7817c7902f76d39440c11b7846b998370abb18377cb5c4e1da7efaa3338fdba24453cdcfd5354812f066a9218b7880973e898fa912601328e6
6
+ metadata.gz: c46ffd65923aafb8bb614664a9f9d74633e651bd16b33c7a8aa95b7f9828c60101479e34b3dfb6b2c0a7986f4dfe80afd768fc7765c1d10823de5363911e64f0
7
+ data.tar.gz: 330ed93426b839ebc65f97ffc65fc92dc9a464a5c830ea3f179d64492f8102230e4970dd2ca599d5040d11e854437723f7b4da3a5b21f5527db2e49ebdf8db61
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.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.create_table :memoized_values, id: false do |t|
6
- t.string :entity_table_name, null: false
7
- t.integer :entity_id, null: false
8
- t.string :method_name, null: false
9
- t.string :arguments_hash
10
- t.binary :value
11
- t.datetime :created_at, null: false
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
- migration.add_index :memoized_values, [:entity_table_name, :entity_id]
15
- migrate_empty_arguments_support(migration)
16
- drop_arguments_support(migration)
17
- add_discrete_value_columns(migration)
18
- end
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
- migration.remove_index :memoized_values, [:entity_id, :entity_table_name]
36
- migration.add_index :memoized_values, [:entity_id, :entity_table_name, :method_name], unique: true, name: 'memoized_attributes_idx2'
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
- def add_discrete_value_columns(migration)
40
- migration.execute 'ALTER TABLE memoized_values ADD COLUMN IF NOT EXISTS val_string varchar'
41
- migration.execute 'ALTER TABLE memoized_values ADD COLUMN IF NOT EXISTS val_integer bigint'
42
- migration.execute 'ALTER TABLE memoized_values ADD COLUMN IF NOT EXISTS val_float double precision'
43
- migration.execute 'ALTER TABLE memoized_values ADD COLUMN IF NOT EXISTS val_time timestamp without time zone'
44
- migration.execute 'ALTER TABLE memoized_values ADD COLUMN IF NOT EXISTS val_boolean boolean'
45
- migration.execute 'ALTER TABLE memoized_values ADD COLUMN IF NOT EXISTS val_object jsonb'
46
- migration.execute 'ALTER TABLE memoized_values ADD COLUMN IF NOT EXISTS val_nil boolean'
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: db_memoize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - johannes-kostas goetzinger