From f46264873e492d2f670b1cdc6c6e7996ed8a93d1 Mon Sep 17 00:00:00 2001 From: ElliottAYoung Date: Mon, 17 Apr 2017 13:50:03 -0500 Subject: [PATCH 1/7] feat: install flipper gems --- Gemfile | 5 +++++ Gemfile.lock | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/Gemfile b/Gemfile index 0474869c8..b6adbefce 100644 --- a/Gemfile +++ b/Gemfile @@ -103,6 +103,11 @@ gem 'ng-rails-csrf', '~> 0.1.0' gem 'bootstrap-tagsinput-rails', '~> 0.4.2' gem 'dialog-polyfill-rails', '~> 0.4.5' +# Feature Flagging +gem 'flipper', '~> 0.10' +gem 'flipper-ui', '~> 0.10' +gem 'flipper-active_record', '~> 0.10' + group :tasks do # Parsing gem 'nokogiri' diff --git a/Gemfile.lock b/Gemfile.lock index 89f0b9be5..137001d14 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -208,6 +208,15 @@ GEM ffi (1.9.17) fission (0.5.0) CFPropertyList (~> 2.2) + flipper (0.10.2) + flipper-active_record (0.10.2) + activerecord (>= 3.2, < 6) + flipper (~> 0.10.2) + flipper-ui (0.10.2) + erubis (~> 2.7.0) + flipper (~> 0.10.2) + rack (>= 1.4, < 3) + rack-protection (>= 1.5.3, < 2.1.0) fog (1.38.0) fog-aliyun (>= 0.1.0) fog-atmos @@ -739,6 +748,9 @@ DEPENDENCIES excon (~> 0.55.0) factory_girl_rails (~> 4.8) faker (~> 1.7) + flipper (~> 0.10) + flipper-active_record (~> 0.10) + flipper-ui (~> 0.10) fog (~> 1.38.0) font-awesome-sass (~> 4.7.0) foreman From af75a0aba5668d5dc1159d6eb37ca6ea57a9c4e1 Mon Sep 17 00:00:00 2001 From: ElliottAYoung Date: Mon, 17 Apr 2017 13:50:11 -0500 Subject: [PATCH 2/7] chore: add flipper initializer --- config/initializers/flipper.rb | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 config/initializers/flipper.rb diff --git a/config/initializers/flipper.rb b/config/initializers/flipper.rb new file mode 100644 index 000000000..273848d1f --- /dev/null +++ b/config/initializers/flipper.rb @@ -0,0 +1,5 @@ +module Cortex + def self.flipper + @flipper ||= Flipper.new(Flipper::Adapters::ActiveRecord.new) + end +end From be5d121519e783232b9df492e40c82dbcaea1c3f Mon Sep 17 00:00:00 2001 From: ElliottAYoung Date: Mon, 17 Apr 2017 13:59:50 -0500 Subject: [PATCH 3/7] feat: build in config logic for Flipper --- config/application.rb | 10 ++++++++++ config/routes.rb | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/config/application.rb b/config/application.rb index 2587cfa20..ad72f9fb4 100644 --- a/config/application.rb +++ b/config/application.rb @@ -40,5 +40,15 @@ class Application < Rails::Application # Needed until there is a better fix for Paperclip. https://github.com/thoughtbot/paperclip/issues/1924#issuecomment-123927367 Paperclip.options[:content_type_mappings] = {:csv => 'text/plain'} + + config.middleware.use Flipper::Middleware::Memoizer, lambda { + Cortex.flipper + } + + Flipper.register(:internal) { |request| request.internal? } + Flipper.register(:authenticated) { |request| request.session[:current_user].present? && request.session[:current_user][:authenticated] } + Flipper.register(:hiring_dot) { |request| request.host == 'admin.cbcortex.com' } + Flipper.register(:dev) { |request| request.host == 'dev.admin.cbcortex.com' || request.host == 'localhost' } + Flipper.register(:staging) { |request| request.host == 'stg.admin.cbcortex.com' } end end diff --git a/config/routes.rb b/config/routes.rb index 7babd0022..cccd95da4 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -35,4 +35,12 @@ # API ::API.logger Rails.logger mount ::API => '/api' + + # Flipper + authenticated :user, lambda {|u| u.is_admin? } do + flipper_block = lambda { + Cortex.flipper + } + mount Flipper::UI.app(flipper_block) => '/flipper' + end end From 9075917d7023d023d420a30c3216f7dac45c7706 Mon Sep 17 00:00:00 2001 From: ElliottAYoung Date: Mon, 17 Apr 2017 14:00:30 -0500 Subject: [PATCH 4/7] chore: run generated flipper migration --- .../20170417185915_create_flipper_tables.rb | 22 +++ db/schema.rb | 178 +++++++++--------- 2 files changed, 114 insertions(+), 86 deletions(-) create mode 100644 db/migrate/20170417185915_create_flipper_tables.rb diff --git a/db/migrate/20170417185915_create_flipper_tables.rb b/db/migrate/20170417185915_create_flipper_tables.rb new file mode 100644 index 000000000..5041e1f31 --- /dev/null +++ b/db/migrate/20170417185915_create_flipper_tables.rb @@ -0,0 +1,22 @@ +class CreateFlipperTables < ActiveRecord::Migration + 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 bc50594c9..db1c93dc3 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: 20170327182543) do +ActiveRecord::Schema.define(version: 20170417185915) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -58,19 +58,14 @@ end create_table "categories", force: :cascade do |t| - t.string "name" - t.integer "user_id", null: false + t.string "name", limit: 255 + t.integer "user_id", null: false t.integer "parent_id" t.integer "lft" t.integer "rgt" t.integer "depth" t.datetime "created_at" t.datetime "updated_at" - t.index ["depth"], name: "index_categories_on_depth", using: :btree - t.index ["lft"], name: "index_categories_on_lft", using: :btree - t.index ["parent_id"], name: "index_categories_on_parent_id", using: :btree - t.index ["rgt"], name: "index_categories_on_rgt", using: :btree - t.index ["user_id"], name: "index_categories_on_user_id", using: :btree end create_table "categories_posts", id: false, force: :cascade do |t| @@ -175,6 +170,22 @@ t.index ["id"], name: "index_fields_on_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 "locales", id: :uuid, default: -> { "uuid_generate_v4()" }, force: :cascade do |t| t.string "name", null: false t.integer "localization_id" @@ -197,24 +208,23 @@ end create_table "media", force: :cascade do |t| - t.string "name" + t.string "name", limit: 255 t.integer "user_id" - t.string "attachment_file_name" - t.string "attachment_content_type" + t.string "attachment_file_name", limit: 255 + t.string "attachment_content_type", limit: 255 t.integer "attachment_file_size" t.datetime "attachment_updated_at" - t.string "dimensions" + t.string "dimensions", limit: 255 t.text "description" - t.string "alt" + t.string "alt", limit: 255 t.boolean "active" t.datetime "deactive_at" t.datetime "created_at" t.datetime "updated_at" - t.string "digest" + t.string "digest", limit: 255 t.datetime "deleted_at" t.hstore "meta" - t.string "type", default: "Media", null: false - t.index ["name"], name: "index_media_on_name", using: :btree + t.string "type", limit: 255, default: "Media", null: false t.index ["user_id"], name: "index_media_on_user_id", using: :btree end @@ -224,48 +234,48 @@ end create_table "oauth_access_grants", force: :cascade do |t| - t.integer "resource_owner_id", null: false - t.integer "application_id", null: false - t.string "token", null: false - t.integer "expires_in", null: false - t.text "redirect_uri", null: false - t.datetime "created_at", null: false + t.integer "resource_owner_id", null: false + t.integer "application_id", null: false + t.string "token", limit: 255, null: false + t.integer "expires_in", null: false + t.text "redirect_uri", null: false + t.datetime "created_at", null: false t.datetime "revoked_at" - t.string "scopes" + t.string "scopes", limit: 255 t.index ["token"], name: "index_oauth_access_grants_on_token", unique: true, using: :btree end create_table "oauth_access_tokens", force: :cascade do |t| t.integer "resource_owner_id" t.integer "application_id" - t.string "token", null: false - t.string "refresh_token" + t.string "token", limit: 255, null: false + t.string "refresh_token", limit: 255 t.integer "expires_in" t.datetime "revoked_at" - t.datetime "created_at", null: false - t.string "scopes" + t.datetime "created_at", null: false + t.string "scopes", limit: 255 t.index ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true, using: :btree t.index ["resource_owner_id"], name: "index_oauth_access_tokens_on_resource_owner_id", using: :btree t.index ["token"], name: "index_oauth_access_tokens_on_token", unique: true, using: :btree end create_table "oauth_applications", force: :cascade do |t| - t.string "name", null: false - t.string "uid", null: false - t.string "secret", null: false - t.text "redirect_uri", null: false + t.string "name", limit: 255, null: false + t.string "uid", limit: 255, null: false + t.string "secret", limit: 255, null: false + t.text "redirect_uri", null: false t.datetime "created_at" t.datetime "updated_at" t.integer "owner_id" - t.string "owner_type" - t.string "scopes", default: "", null: false + t.string "owner_type", limit: 255 + t.string "scopes", default: "", null: false t.index ["owner_id", "owner_type"], name: "index_oauth_applications_on_owner_id_and_owner_type", using: :btree t.index ["uid"], name: "index_oauth_applications_on_uid", unique: true, using: :btree end create_table "onet_occupations", force: :cascade do |t| - t.string "soc" - t.string "title" + t.string "soc", limit: 255 + t.string "title", limit: 255 t.text "description" t.datetime "created_at" t.datetime "updated_at" @@ -285,45 +295,44 @@ end create_table "posts", force: :cascade do |t| - t.integer "user_id", null: false - t.string "title" + t.integer "user_id", null: false + t.string "title", limit: 255 t.datetime "published_at" t.datetime "expired_at" t.datetime "deleted_at" - t.boolean "draft", default: true, null: false - t.integer "comment_count", default: 0, null: false + t.boolean "draft", default: true, null: false + t.integer "comment_count", default: 0, null: false t.text "body" t.datetime "created_at" t.datetime "updated_at" - t.string "short_description" - t.integer "job_phase", null: false - t.integer "display", null: false + t.string "short_description", limit: 255 + t.integer "job_phase", null: false + t.integer "display", null: false t.text "notes" - t.string "copyright_owner" - t.string "seo_title" - t.string "seo_description" - t.string "seo_preview" - t.string "custom_author" - t.string "slug", null: false + t.string "copyright_owner", limit: 255 + t.string "seo_title", limit: 255 + t.string "seo_description", limit: 255 + t.string "seo_preview", limit: 255 + t.string "custom_author", limit: 255 + t.string "slug", null: false t.integer "featured_media_id" t.integer "primary_industry_id" t.integer "primary_category_id" t.integer "tile_media_id" t.hstore "meta" - t.string "type", default: "Post", null: false + t.string "type", default: "Post", null: false t.integer "author_id" - t.boolean "is_wysiwyg", default: true - t.boolean "noindex", default: false - t.boolean "nofollow", default: false - t.boolean "nosnippet", default: false - t.boolean "noodp", default: false - t.boolean "noarchive", default: false - t.boolean "noimageindex", default: false - t.boolean "is_sticky", default: false + t.boolean "is_wysiwyg", default: true + t.boolean "noindex", default: false + t.boolean "nofollow", default: false + t.boolean "nosnippet", default: false + t.boolean "noodp", default: false + t.boolean "noarchive", default: false + t.boolean "noimageindex", default: false + t.boolean "is_sticky", default: false t.index ["author_id"], name: "index_posts_on_author_id", using: :btree t.index ["slug"], name: "index_posts_on_slug", using: :btree t.index ["type"], name: "index_posts_on_type", using: :btree - t.index ["user_id"], name: "index_posts_on_user_id", using: :btree end create_table "role_permissions", force: :cascade do |t| @@ -335,11 +344,10 @@ create_table "roles", force: :cascade do |t| t.string "name" + t.datetime "created_at" + t.datetime "updated_at" t.string "resource_type" - t.integer "resource_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false - t.index ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id", using: :btree + t.string "resource_id" t.index ["name"], name: "index_roles_on_name", using: :btree end @@ -355,10 +363,10 @@ create_table "taggings", force: :cascade do |t| t.integer "tag_id" - t.string "taggable_type" t.integer "taggable_id" - t.string "tagger_type" + t.string "taggable_type", limit: 255 t.integer "tagger_id" + t.string "tagger_type", limit: 255 t.string "context", limit: 128 t.datetime "created_at" t.index ["context"], name: "index_taggings_on_context", using: :btree @@ -373,8 +381,9 @@ end create_table "tags", force: :cascade do |t| - t.string "name" - t.integer "taggings_count", default: 0 + t.string "name", limit: 255 + t.integer "taggings_count", default: 0 + t.integer "tenant_id", default: 1 t.index ["name"], name: "index_tags_on_name", unique: true, using: :btree end @@ -389,47 +398,43 @@ t.string "contact_email", limit: 200 t.string "contact_phone", limit: 20 t.datetime "deleted_at" - t.string "contract" - t.string "did" + t.string "contract", limit: 255 + t.string "did", limit: 255 t.datetime "active_at" t.datetime "deactive_at" t.integer "owner_id" t.datetime "created_at" t.datetime "updated_at" - t.index ["did"], name: "index_tenants_on_did", using: :btree - t.index ["owner_id"], name: "index_tenants_on_owner_id", using: :btree t.index ["parent_id"], name: "index_tenants_on_parent_id", using: :btree end create_table "users", force: :cascade do |t| - t.string "email", default: "", null: false + t.string "email", limit: 255, default: "", null: false t.datetime "created_at" t.datetime "updated_at" - t.integer "tenant_id", null: false - t.string "encrypted_password", default: "", null: false - t.string "reset_password_token" + t.integer "tenant_id", null: false + t.string "encrypted_password", limit: 255, default: "", null: false + t.string "reset_password_token", limit: 255 t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0, null: false + t.integer "sign_in_count", default: 0, null: false t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" - t.string "current_sign_in_ip" - t.string "last_sign_in_ip" - t.string "firstname", null: false - t.string "lastname" - t.string "locale", limit: 30, default: "en_US", null: false - t.string "timezone", limit: 30, default: "EST", null: false - t.boolean "admin", default: false, null: false + t.string "current_sign_in_ip", limit: 255 + t.string "last_sign_in_ip", limit: 255 + t.string "firstname", limit: 255, null: false + t.string "lastname", limit: 255 + t.string "locale", limit: 30, default: "en_US", null: false + t.string "timezone", limit: 30, default: "EST", null: false + t.boolean "admin", default: false, null: false t.index ["email"], name: "index_users_on_email", unique: true, using: :btree t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree t.index ["tenant_id"], name: "index_users_on_tenant_id", using: :btree end create_table "users_roles", id: false, force: :cascade do |t| - t.integer "user_id" - t.integer "role_id" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.integer "user_id" + t.integer "role_id" t.index ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id", using: :btree end @@ -452,6 +457,7 @@ t.boolean "noodp", default: false t.boolean "noarchive", default: false t.boolean "noimageindex", default: false + t.text "seo_keywords" t.string "dynamic_yield_sku" t.string "dynamic_yield_category" t.jsonb "tables_widget" From 65777456bb656b19cfddf7aee595fb846d8a8878 Mon Sep 17 00:00:00 2001 From: ElliottAYoung Date: Mon, 17 Apr 2017 14:03:01 -0500 Subject: [PATCH 5/7] feat: add flag_enabled? method to application_helper --- app/helpers/application_helper.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 2161cdcb0..407de01a5 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -12,4 +12,8 @@ def extra_config def qualtrics_domain extra_config.qualtrics_id.delete('_').downcase end + + def flag_enabled?(flag_name) + Cortex.flipper[flag_name].enabled?(current_user, request) + end end From fe230097b432479ac8733bdb2ed3977246114bbd Mon Sep 17 00:00:00 2001 From: ElliottAYoung Date: Wed, 19 Apr 2017 14:01:48 -0500 Subject: [PATCH 6/7] refactor: move flipper groupings into initializer --- config/application.rb | 10 ---------- config/initializers/flipper.rb | 8 ++++++++ 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/config/application.rb b/config/application.rb index ad72f9fb4..2587cfa20 100644 --- a/config/application.rb +++ b/config/application.rb @@ -40,15 +40,5 @@ class Application < Rails::Application # Needed until there is a better fix for Paperclip. https://github.com/thoughtbot/paperclip/issues/1924#issuecomment-123927367 Paperclip.options[:content_type_mappings] = {:csv => 'text/plain'} - - config.middleware.use Flipper::Middleware::Memoizer, lambda { - Cortex.flipper - } - - Flipper.register(:internal) { |request| request.internal? } - Flipper.register(:authenticated) { |request| request.session[:current_user].present? && request.session[:current_user][:authenticated] } - Flipper.register(:hiring_dot) { |request| request.host == 'admin.cbcortex.com' } - Flipper.register(:dev) { |request| request.host == 'dev.admin.cbcortex.com' || request.host == 'localhost' } - Flipper.register(:staging) { |request| request.host == 'stg.admin.cbcortex.com' } end end diff --git a/config/initializers/flipper.rb b/config/initializers/flipper.rb index 273848d1f..db3d70fc0 100644 --- a/config/initializers/flipper.rb +++ b/config/initializers/flipper.rb @@ -3,3 +3,11 @@ def self.flipper @flipper ||= Flipper.new(Flipper::Adapters::ActiveRecord.new) end end + +Cortex::Application.config.middleware.use Flipper::Middleware::Memoizer, Cortex.flipper + +Flipper.register(:internal) { |request| request.internal? } +Flipper.register(:authenticated) { |request| request.session[:current_user].present? && request.session[:current_user][:authenticated] } +Flipper.register(:cortex) { |request| request.host == 'admin.cbcortex.com' } +Flipper.register(:dev) { |request| request.host == 'dev.admin.cbcortex.com' || request.host == 'localhost' } +Flipper.register(:staging) { |request| request.host == 'stg.admin.cbcortex.com' } From 609ff913f5b7210d343b968a89de339aa2096be5 Mon Sep 17 00:00:00 2001 From: ElliottAYoung Date: Wed, 19 Apr 2017 14:03:39 -0500 Subject: [PATCH 7/7] refactor: clean noise from schema file --- db/schema.rb | 162 +++++++++++++++++++++++++++------------------------ 1 file changed, 86 insertions(+), 76 deletions(-) diff --git a/db/schema.rb b/db/schema.rb index db1c93dc3..ddaf9127f 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: 20170417185915) do +ActiveRecord::Schema.define(version: 20170327182543) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -58,14 +58,19 @@ end create_table "categories", force: :cascade do |t| - t.string "name", limit: 255 - t.integer "user_id", null: false + t.string "name" + t.integer "user_id", null: false t.integer "parent_id" t.integer "lft" t.integer "rgt" t.integer "depth" t.datetime "created_at" t.datetime "updated_at" + t.index ["depth"], name: "index_categories_on_depth", using: :btree + t.index ["lft"], name: "index_categories_on_lft", using: :btree + t.index ["parent_id"], name: "index_categories_on_parent_id", using: :btree + t.index ["rgt"], name: "index_categories_on_rgt", using: :btree + t.index ["user_id"], name: "index_categories_on_user_id", using: :btree end create_table "categories_posts", id: false, force: :cascade do |t| @@ -208,23 +213,24 @@ end create_table "media", force: :cascade do |t| - t.string "name", limit: 255 + t.string "name" t.integer "user_id" - t.string "attachment_file_name", limit: 255 - t.string "attachment_content_type", limit: 255 + t.string "attachment_file_name" + t.string "attachment_content_type" t.integer "attachment_file_size" t.datetime "attachment_updated_at" - t.string "dimensions", limit: 255 + t.string "dimensions" t.text "description" - t.string "alt", limit: 255 + t.string "alt" t.boolean "active" t.datetime "deactive_at" t.datetime "created_at" t.datetime "updated_at" - t.string "digest", limit: 255 + t.string "digest" t.datetime "deleted_at" t.hstore "meta" - t.string "type", limit: 255, default: "Media", null: false + t.string "type", default: "Media", null: false + t.index ["name"], name: "index_media_on_name", using: :btree t.index ["user_id"], name: "index_media_on_user_id", using: :btree end @@ -234,48 +240,48 @@ end create_table "oauth_access_grants", force: :cascade do |t| - t.integer "resource_owner_id", null: false - t.integer "application_id", null: false - t.string "token", limit: 255, null: false - t.integer "expires_in", null: false - t.text "redirect_uri", null: false - t.datetime "created_at", null: false + t.integer "resource_owner_id", null: false + t.integer "application_id", null: false + t.string "token", null: false + t.integer "expires_in", null: false + t.text "redirect_uri", null: false + t.datetime "created_at", null: false t.datetime "revoked_at" - t.string "scopes", limit: 255 + t.string "scopes" t.index ["token"], name: "index_oauth_access_grants_on_token", unique: true, using: :btree end create_table "oauth_access_tokens", force: :cascade do |t| t.integer "resource_owner_id" t.integer "application_id" - t.string "token", limit: 255, null: false - t.string "refresh_token", limit: 255 + t.string "token", null: false + t.string "refresh_token" t.integer "expires_in" t.datetime "revoked_at" - t.datetime "created_at", null: false - t.string "scopes", limit: 255 + t.datetime "created_at", null: false + t.string "scopes" t.index ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true, using: :btree t.index ["resource_owner_id"], name: "index_oauth_access_tokens_on_resource_owner_id", using: :btree t.index ["token"], name: "index_oauth_access_tokens_on_token", unique: true, using: :btree end create_table "oauth_applications", force: :cascade do |t| - t.string "name", limit: 255, null: false - t.string "uid", limit: 255, null: false - t.string "secret", limit: 255, null: false - t.text "redirect_uri", null: false + t.string "name", null: false + t.string "uid", null: false + t.string "secret", null: false + t.text "redirect_uri", null: false t.datetime "created_at" t.datetime "updated_at" t.integer "owner_id" - t.string "owner_type", limit: 255 - t.string "scopes", default: "", null: false + t.string "owner_type" + t.string "scopes", default: "", null: false t.index ["owner_id", "owner_type"], name: "index_oauth_applications_on_owner_id_and_owner_type", using: :btree t.index ["uid"], name: "index_oauth_applications_on_uid", unique: true, using: :btree end create_table "onet_occupations", force: :cascade do |t| - t.string "soc", limit: 255 - t.string "title", limit: 255 + t.string "soc" + t.string "title" t.text "description" t.datetime "created_at" t.datetime "updated_at" @@ -295,44 +301,45 @@ end create_table "posts", force: :cascade do |t| - t.integer "user_id", null: false - t.string "title", limit: 255 + t.integer "user_id", null: false + t.string "title" t.datetime "published_at" t.datetime "expired_at" t.datetime "deleted_at" - t.boolean "draft", default: true, null: false - t.integer "comment_count", default: 0, null: false + t.boolean "draft", default: true, null: false + t.integer "comment_count", default: 0, null: false t.text "body" t.datetime "created_at" t.datetime "updated_at" - t.string "short_description", limit: 255 - t.integer "job_phase", null: false - t.integer "display", null: false + t.string "short_description" + t.integer "job_phase", null: false + t.integer "display", null: false t.text "notes" - t.string "copyright_owner", limit: 255 - t.string "seo_title", limit: 255 - t.string "seo_description", limit: 255 - t.string "seo_preview", limit: 255 - t.string "custom_author", limit: 255 - t.string "slug", null: false + t.string "copyright_owner" + t.string "seo_title" + t.string "seo_description" + t.string "seo_preview" + t.string "custom_author" + t.string "slug", null: false t.integer "featured_media_id" t.integer "primary_industry_id" t.integer "primary_category_id" t.integer "tile_media_id" t.hstore "meta" - t.string "type", default: "Post", null: false + t.string "type", default: "Post", null: false t.integer "author_id" - t.boolean "is_wysiwyg", default: true - t.boolean "noindex", default: false - t.boolean "nofollow", default: false - t.boolean "nosnippet", default: false - t.boolean "noodp", default: false - t.boolean "noarchive", default: false - t.boolean "noimageindex", default: false - t.boolean "is_sticky", default: false + t.boolean "is_wysiwyg", default: true + t.boolean "noindex", default: false + t.boolean "nofollow", default: false + t.boolean "nosnippet", default: false + t.boolean "noodp", default: false + t.boolean "noarchive", default: false + t.boolean "noimageindex", default: false + t.boolean "is_sticky", default: false t.index ["author_id"], name: "index_posts_on_author_id", using: :btree t.index ["slug"], name: "index_posts_on_slug", using: :btree t.index ["type"], name: "index_posts_on_type", using: :btree + t.index ["user_id"], name: "index_posts_on_user_id", using: :btree end create_table "role_permissions", force: :cascade do |t| @@ -344,10 +351,11 @@ create_table "roles", force: :cascade do |t| t.string "name" - t.datetime "created_at" - t.datetime "updated_at" t.string "resource_type" - t.string "resource_id" + t.integer "resource_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["name", "resource_type", "resource_id"], name: "index_roles_on_name_and_resource_type_and_resource_id", using: :btree t.index ["name"], name: "index_roles_on_name", using: :btree end @@ -363,10 +371,10 @@ create_table "taggings", force: :cascade do |t| t.integer "tag_id" + t.string "taggable_type" t.integer "taggable_id" - t.string "taggable_type", limit: 255 + t.string "tagger_type" t.integer "tagger_id" - t.string "tagger_type", limit: 255 t.string "context", limit: 128 t.datetime "created_at" t.index ["context"], name: "index_taggings_on_context", using: :btree @@ -381,9 +389,8 @@ end create_table "tags", force: :cascade do |t| - t.string "name", limit: 255 - t.integer "taggings_count", default: 0 - t.integer "tenant_id", default: 1 + t.string "name" + t.integer "taggings_count", default: 0 t.index ["name"], name: "index_tags_on_name", unique: true, using: :btree end @@ -398,43 +405,47 @@ t.string "contact_email", limit: 200 t.string "contact_phone", limit: 20 t.datetime "deleted_at" - t.string "contract", limit: 255 - t.string "did", limit: 255 + t.string "contract" + t.string "did" t.datetime "active_at" t.datetime "deactive_at" t.integer "owner_id" t.datetime "created_at" t.datetime "updated_at" + t.index ["did"], name: "index_tenants_on_did", using: :btree + t.index ["owner_id"], name: "index_tenants_on_owner_id", using: :btree t.index ["parent_id"], name: "index_tenants_on_parent_id", using: :btree end create_table "users", force: :cascade do |t| - t.string "email", limit: 255, default: "", null: false + t.string "email", default: "", null: false t.datetime "created_at" t.datetime "updated_at" - t.integer "tenant_id", null: false - t.string "encrypted_password", limit: 255, default: "", null: false - t.string "reset_password_token", limit: 255 + t.integer "tenant_id", null: false + t.string "encrypted_password", default: "", null: false + t.string "reset_password_token" t.datetime "reset_password_sent_at" t.datetime "remember_created_at" - t.integer "sign_in_count", default: 0, null: false + t.integer "sign_in_count", default: 0, null: false t.datetime "current_sign_in_at" t.datetime "last_sign_in_at" - t.string "current_sign_in_ip", limit: 255 - t.string "last_sign_in_ip", limit: 255 - t.string "firstname", limit: 255, null: false - t.string "lastname", limit: 255 - t.string "locale", limit: 30, default: "en_US", null: false - t.string "timezone", limit: 30, default: "EST", null: false - t.boolean "admin", default: false, null: false + t.string "current_sign_in_ip" + t.string "last_sign_in_ip" + t.string "firstname", null: false + t.string "lastname" + t.string "locale", limit: 30, default: "en_US", null: false + t.string "timezone", limit: 30, default: "EST", null: false + t.boolean "admin", default: false, null: false t.index ["email"], name: "index_users_on_email", unique: true, using: :btree t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree t.index ["tenant_id"], name: "index_users_on_tenant_id", using: :btree end create_table "users_roles", id: false, force: :cascade do |t| - t.integer "user_id" - t.integer "role_id" + t.integer "user_id" + t.integer "role_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.index ["user_id", "role_id"], name: "index_users_roles_on_user_id_and_role_id", using: :btree end @@ -457,7 +468,6 @@ t.boolean "noodp", default: false t.boolean "noarchive", default: false t.boolean "noimageindex", default: false - t.text "seo_keywords" t.string "dynamic_yield_sku" t.string "dynamic_yield_category" t.jsonb "tables_widget"