File: active_record_setup.rb

package info (click to toggle)
ruby-flipper 0.26.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,288 kB
  • sloc: ruby: 16,377; sh: 61; javascript: 24; makefile: 14
file content (31 lines) | stat: -rw-r--r-- 761 bytes parent folder | download
1
2
3
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
31
require 'bundler/setup'
require 'active_record'

ActiveRecord::Base.establish_connection({
  adapter: 'sqlite3',
  database: ':memory:',
})

ActiveRecord::Base.connection.execute <<-SQL
  CREATE TABLE flipper_features (
    id integer PRIMARY KEY,
    key text NOT NULL UNIQUE,
    created_at datetime NOT NULL,
    updated_at datetime NOT NULL
  )
SQL

ActiveRecord::Base.connection.execute <<-SQL
  CREATE TABLE flipper_gates (
    id integer PRIMARY KEY,
    feature_key text NOT NULL,
    key text NOT NULL,
    value text DEFAULT NULL,
    created_at datetime NOT NULL,
    updated_at datetime NOT NULL
  )
SQL

ActiveRecord::Base.connection.execute <<-SQL
  CREATE UNIQUE INDEX index_gates_on_keys_and_value on flipper_gates (feature_key, key, value)
SQL