From ad71f925be8f86b442839aa83d3bbd02ab5702da Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Bellet Date: Thu, 1 Apr 2021 11:18:20 +0200 Subject: [PATCH] Add gem flipper-active_record to store flipper data - Creates the migration for flipper: `flipper_features` and `flipper_gates` --- Gemfile | 1 + Gemfile.lock | 4 +++ .../20210326094519_create_flipper_tables.rb | 22 ++++++++++++++ db/schema.rb | 30 ++++++++++++++----- 4 files changed, 50 insertions(+), 7 deletions(-) create mode 100644 db/migrate/20210326094519_create_flipper_tables.rb diff --git a/Gemfile b/Gemfile index 0069ffd3f8..6b512cebd3 100644 --- a/Gemfile +++ b/Gemfile @@ -114,6 +114,7 @@ gem 'ofn-qz', github: 'openfoodfoundation/ofn-qz', branch: 'ofn-rails-4' gem 'good_migrations' gem 'flipper' +gem 'flipper-active_record' gem 'flipper-ui' group :production, :staging do diff --git a/Gemfile.lock b/Gemfile.lock index 6fba30ba60..cd0ad8a269 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -234,6 +234,9 @@ GEM figaro (1.2.0) thor (>= 0.14.0, < 2) flipper (0.20.4) + flipper-active_record (0.20.4) + activerecord (>= 5.0, < 7) + flipper (~> 0.20.4) flipper-ui (0.20.4) erubi (>= 1.0.0, < 2.0.0) flipper (~> 0.20.4) @@ -649,6 +652,7 @@ DEPENDENCIES ffaker figaro flipper + flipper-active_record flipper-ui fog-aws (>= 0.6.0) foundation-icons-sass-rails diff --git a/db/migrate/20210326094519_create_flipper_tables.rb b/db/migrate/20210326094519_create_flipper_tables.rb new file mode 100644 index 0000000000..e7b94de750 --- /dev/null +++ b/db/migrate/20210326094519_create_flipper_tables.rb @@ -0,0 +1,22 @@ +class CreateFlipperTables < ActiveRecord::Migration[5.0] + def self.up + create_table :flipper_features do |t| + t.string :key, null: false + t.timestamps null: false + end + add_index :flipper_features, :key, unique: true + + create_table :flipper_gates do |t| + t.string :feature_key, null: false + t.string :key, null: false + t.string :value + t.timestamps null: false + end + add_index :flipper_gates, [:feature_key, :key, :value], unique: true + end + + def self.down + drop_table :flipper_gates + drop_table :flipper_features + end +end diff --git a/db/schema.rb b/db/schema.rb index 92c4a23937..310cc0420f 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20210407170804) do +ActiveRecord::Schema.define(version: 20210326094519) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -250,6 +250,22 @@ ActiveRecord::Schema.define(version: 20210407170804) do t.index ["sender_id"], name: "index_exchanges_on_sender_id", using: :btree end + create_table "flipper_features", force: :cascade do |t| + t.string "key", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["key"], name: "index_flipper_features_on_key", unique: true, using: :btree + end + + create_table "flipper_gates", force: :cascade do |t| + t.string "feature_key", null: false + t.string "key", null: false + t.string "value" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["feature_key", "key", "value"], name: "index_flipper_gates_on_feature_key_and_key_and_value", unique: true, using: :btree + end + create_table "inventory_items", force: :cascade do |t| t.integer "enterprise_id", null: false t.integer "variant_id", null: false @@ -769,15 +785,15 @@ ActiveRecord::Schema.define(version: 20210407170804) do end create_table "spree_shipments", force: :cascade do |t| - t.string "tracking", limit: 255 - t.string "number", limit: 255 - t.decimal "cost", precision: 10, scale: 2, default: "0.0", null: false + t.string "tracking", limit: 255 + t.string "number", limit: 255 + t.decimal "cost", precision: 10, scale: 2, default: "0.0", null: false t.datetime "shipped_at" t.integer "order_id" t.integer "address_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.string "state", limit: 255 + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "state", limit: 255 t.integer "stock_location_id" t.decimal "included_tax_total", precision: 10, scale: 2, default: "0.0", null: false t.decimal "additional_tax_total", precision: 10, scale: 2, default: "0.0", null: false