Initial commit

This commit is contained in:
Senad Uka
2021-09-20 08:22:39 +02:00
commit a0c72b0caf
133 changed files with 9056 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
# frozen_string_literal: true
class DeviseCreateAdminUsers < ActiveRecord::Migration[6.1]
def change
create_table :admin_users do |t|
## Database authenticatable
t.string :email, null: false, default: ""
t.string :encrypted_password, null: false, default: ""
## Recoverable
t.string :reset_password_token
t.datetime :reset_password_sent_at
## Rememberable
t.datetime :remember_created_at
## Trackable
# 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
## Confirmable
# t.string :confirmation_token
# t.datetime :confirmed_at
# t.datetime :confirmation_sent_at
# t.string :unconfirmed_email # Only if using reconfirmable
## Lockable
# t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
# t.string :unlock_token # Only if unlock strategy is :email or :both
# t.datetime :locked_at
t.timestamps null: false
end
add_index :admin_users, :email, unique: true
add_index :admin_users, :reset_password_token, unique: true
# add_index :admin_users, :confirmation_token, unique: true
# add_index :admin_users, :unlock_token, unique: true
end
end

View File

@@ -0,0 +1,16 @@
class CreateActiveAdminComments < ActiveRecord::Migration[6.1]
def self.up
create_table :active_admin_comments do |t|
t.string :namespace
t.text :body
t.references :resource, polymorphic: true
t.references :author, polymorphic: true
t.timestamps
end
add_index :active_admin_comments, [:namespace]
end
def self.down
drop_table :active_admin_comments
end
end

View File

@@ -0,0 +1,32 @@
class CreateSubscriptions < ActiveRecord::Migration[6.1]
def change
create_table :subscriptions do |t|
t.string :contact
t.integer :licenses_count
t.string :name
t.string :supplier_name
t.string :industry_name
t.string :product_name
t.integer :licese_type
t.integer :max_users
t.date :starts_at
t.date :ends_at
t.integer :active_licenses_count
t.text :notes
t.boolean :is_autorenew
t.integer :autorenew_duration
t.string :autorenew_duration_unit, :duration_unit, null: false, default: 'month'
t.date :autorenew_deadline
t.string :billing_frequency
t.string :contract_entity_name
t.date :autorenew_voided_at
t.date :renewed_at
t.decimal :retention, precision: 17, scale: 2, null: true
t.string :limit
t.integer :retention_currency_id
t.boolean :has_percentage_discount_type
t.boolean :has_flat_fare_discount_type
t.timestamps
end
end
end

View File

@@ -0,0 +1,24 @@
class CreateEmployers < ActiveRecord::Migration[6.1]
def change
create_table :employers do |t|
t.string "name"
t.string "logo_url"
t.string "short_name"
t.string "short_code"
t.integer "users_count", default: 0
t.integer "subscriptions_count", default: 0
t.string "status"
t.boolean "user_set_status", default: false
t.bigint "primary_contact_id"
t.integer "savings_report_frequency_in_months", default: 3, null: false
t.date "first_joined_at"
t.string "org_type", default: "member", null: false
t.bigint "asana_assignee_id"
t.index ["asana_assignee_id"], name: "index_employers_on_asana_assignee_id"
t.index ["first_joined_at"], name: "index_employers_on_first_joined_at"
t.index ["org_type"], name: "index_employers_on_org_type"
t.index ["primary_contact_id"], name: "index_employers_on_primary_contact_id"
t.timestamps
end
end
end

View File

@@ -0,0 +1,5 @@
class AddEmployerToSubscription < ActiveRecord::Migration[6.1]
def change
add_reference :subscriptions, :employer, null: false, foreign_key: true
end
end

View File

@@ -0,0 +1,5 @@
class AddSeriesSuccessorIdToSubscriptions < ActiveRecord::Migration[6.1]
def change
add_column :subscriptions, :series_successor_id, :integer
end
end

View File

@@ -0,0 +1,5 @@
class AddSeriesTerminatedAtToSubscriptions < ActiveRecord::Migration[6.1]
def change
add_column :subscriptions, :terminated_at, :date
end
end

View File

@@ -0,0 +1,8 @@
class CreateSuppliers < ActiveRecord::Migration[6.1]
def change
create_table :suppliers do |t|
t.string "name"
t.timestamps
end
end
end

View File

@@ -0,0 +1,11 @@
class CreateProducts < ActiveRecord::Migration[6.1]
def change
create_table :products do |t|
t.string "name"
t.bigint "industry_id"
t.bigint "supplier_id"
t.string "description"
t.timestamps
end
end
end

114
db/schema.rb generated Normal file
View File

@@ -0,0 +1,114 @@
# This file is auto-generated from the current state of the database. Instead
# of editing this file, please use the migrations feature of Active Record to
# incrementally modify your database, and then regenerate this schema definition.
#
# This file is the source Rails uses to define your schema when running `bin/rails
# db:schema:load`. When creating a new database, `bin/rails db:schema:load` tends to
# be faster and is potentially less error prone than running all of your
# migrations from scratch. Old migrations may fail to apply correctly if those
# migrations use external dependencies or application code.
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 2021_09_17_144722) do
create_table "active_admin_comments", force: :cascade do |t|
t.string "namespace"
t.text "body"
t.string "resource_type"
t.integer "resource_id"
t.string "author_type"
t.integer "author_id"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["author_type", "author_id"], name: "index_active_admin_comments_on_author"
t.index ["namespace"], name: "index_active_admin_comments_on_namespace"
t.index ["resource_type", "resource_id"], name: "index_active_admin_comments_on_resource"
end
create_table "admin_users", force: :cascade do |t|
t.string "email", default: "", 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.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["email"], name: "index_admin_users_on_email", unique: true
t.index ["reset_password_token"], name: "index_admin_users_on_reset_password_token", unique: true
end
create_table "employers", force: :cascade do |t|
t.string "name"
t.string "logo_url"
t.string "short_name"
t.string "short_code"
t.integer "users_count", default: 0
t.integer "subscriptions_count", default: 0
t.string "status"
t.boolean "user_set_status", default: false
t.bigint "primary_contact_id"
t.integer "savings_report_frequency_in_months", default: 3, null: false
t.date "first_joined_at"
t.string "org_type", default: "member", null: false
t.bigint "asana_assignee_id"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.index ["asana_assignee_id"], name: "index_employers_on_asana_assignee_id"
t.index ["first_joined_at"], name: "index_employers_on_first_joined_at"
t.index ["org_type"], name: "index_employers_on_org_type"
t.index ["primary_contact_id"], name: "index_employers_on_primary_contact_id"
end
create_table "products", force: :cascade do |t|
t.string "name"
t.bigint "industry_id"
t.bigint "supplier_id"
t.string "description"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
create_table "subscriptions", force: :cascade do |t|
t.string "contact"
t.integer "licenses_count"
t.string "name"
t.string "supplier_name"
t.string "industry_name"
t.string "product_name"
t.integer "licese_type"
t.integer "max_users"
t.date "starts_at"
t.date "ends_at"
t.integer "active_licenses_count"
t.text "notes"
t.boolean "is_autorenew"
t.integer "autorenew_duration"
t.string "autorenew_duration_unit", default: "month", null: false
t.string "duration_unit", default: "month", null: false
t.date "autorenew_deadline"
t.string "billing_frequency"
t.string "contract_entity_name"
t.date "autorenew_voided_at"
t.date "renewed_at"
t.decimal "retention", precision: 17, scale: 2
t.string "limit"
t.integer "retention_currency_id"
t.boolean "has_percentage_discount_type"
t.boolean "has_flat_fare_discount_type"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
t.integer "employer_id", null: false
t.integer "series_successor_id"
t.date "terminated_at"
t.index ["employer_id"], name: "index_subscriptions_on_employer_id"
end
create_table "suppliers", force: :cascade do |t|
t.string "name"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
add_foreign_key "subscriptions", "employers"
end

8
db/seeds.rb Normal file
View File

@@ -0,0 +1,8 @@
# This file should contain all the record creation needed to seed the database with its default values.
# The data can then be loaded with the bin/rails db:seed command (or created alongside the database with db:setup).
#
# Examples:
#
# movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }])
# Character.create(name: 'Luke', movie: movies.first)
AdminUser.create!(email: 'admin@example.com', password: 'password', password_confirmation: 'password') if Rails.env.development?