Class: DbMemoize::Migrations

Inherits:
Object
  • Object
show all
Defined in:
lib/db_memoize/migrations.rb

Class Method Summary collapse

Class Method Details

.create_tables(migration) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/db_memoize/migrations.rb', line 4

def create_tables(migration)
  migration.execute "    CREATE SCHEMA IF NOT EXISTS db_memoize;\n\n    CREATE TABLE IF NOT EXISTS db_memoize.memoized_values (\n      entity_table_name varchar NOT NULL,\n      entity_id         integer NOT NULL,\n      method_name       varchar NOT NULL,\n\n      val_string        varchar,\n      val_integer       bigint,\n      val_float         double precision,\n      val_time          timestamp without time zone,\n      val_object        jsonb,\n      val_boolean       boolean,\n      val_nil           boolean,\n      created_at        timestamp without time zone NOT NULL\n    );\n\n    -- entity_id/entity_table_name should have a better chance to be useful, since\n    -- there is more variance in entity_ids than there is in entity_table_names.\n    DROP INDEX IF EXISTS db_memoize.memoized_attributes_idx2;\n\n    CREATE INDEX IF NOT EXISTS memoized_attributes_idx3\n      ON db_memoize.memoized_values(entity_id, entity_table_name);\n  SQL\nend\n"