aboutsummaryrefslogtreecommitdiffstats
path: root/db/schema.rb
diff options
context:
space:
mode:
authorsadbeast <sadbeast@sadbeast.com>2024-01-31 17:47:56 -0800
committersadbeast <sadbeast@sadbeast.com>2024-01-31 17:47:56 -0800
commit332ec93366315fa1ed7b4acd7a3407c96e8ddfa7 (patch)
tree6ae553317f12a7a6a29c849c8805ffab96436dc2 /db/schema.rb
downloadtd-332ec93366315fa1ed7b4acd7a3407c96e8ddfa7.tar.gz
td-332ec93366315fa1ed7b4acd7a3407c96e8ddfa7.tar.bz2
initial mistakeHEADmain
Diffstat (limited to 'db/schema.rb')
-rw-r--r--db/schema.rb126
1 files changed, 126 insertions, 0 deletions
diff --git a/db/schema.rb b/db/schema.rb
new file mode 100644
index 0000000..fbe0b4e
--- /dev/null
+++ b/db/schema.rb
@@ -0,0 +1,126 @@
+# 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[7.1].define(version: 0) do
+ create_schema "teamdraft"
+
+ # These are extensions that must be enabled in order to support this database
+ enable_extension "plpgsql"
+
+ # Custom types defined in this database.
+ # Note that some types may not work with other database engines. Be careful if changing database.
+ create_enum "divisions", ["nfcn", "nfce", "nfcs", "nfcw", "afcn", "afce", "afcs", "afcw"]
+ create_enum "score_category", ["win", "playoffs", "divisional", "conference", "superbowl", "champion"]
+
+ create_table "drafts", primary_key: "draft_id", id: :integer, default: nil, force: :cascade do |t|
+ t.integer "league_season_id", null: false
+ t.timestamptz "started_at", null: false
+ t.timestamptz "created_at", default: -> { "now()" }, null: false
+ t.timestamptz "modified_at", default: -> { "now()" }, null: false
+ end
+
+ create_table "league_seasons", primary_key: "league_season_id", id: :integer, default: nil, force: :cascade do |t|
+ t.integer "season_id", limit: 2, null: false
+ t.integer "league_id", null: false
+ t.timestamptz "created_at", default: -> { "now()" }, null: false
+ t.timestamptz "modified_at", default: -> { "now()" }, null: false
+ end
+
+ create_table "league_users", primary_key: "league_user_id", id: :bigint, default: nil, force: :cascade do |t|
+ t.integer "league_season_id", null: false
+ t.integer "user_id", null: false
+ t.timestamptz "created_at", default: -> { "now()" }, null: false
+ t.timestamptz "modified_at", default: -> { "now()" }, null: false
+ end
+
+ create_table "leagues", primary_key: "league_id", id: :integer, default: nil, force: :cascade do |t|
+ t.text "name"
+ t.integer "user_id", null: false
+ t.timestamptz "created_at", default: -> { "now()" }, null: false
+ t.timestamptz "modified_at", default: -> { "now()" }, null: false
+ t.check_constraint "char_length(name) <= 255", name: "leagues_name_ck"
+ end
+
+ create_table "picks", primary_key: "pick_id", id: :integer, default: nil, force: :cascade do |t|
+ t.integer "draft_id", null: false
+ t.integer "league_user_id", null: false
+ t.integer "team_id", limit: 2, null: false
+ t.boolean "auto", default: false, null: false
+ t.timestamptz "created_at", default: -> { "now()" }, null: false
+ t.timestamptz "modified_at", default: -> { "now()" }, null: false
+ end
+
+ create_table "rankings", primary_key: "ranking_id", id: :integer, default: nil, force: :cascade do |t|
+ t.integer "season_id", null: false
+ t.integer "team_id", null: false
+ t.integer "rank", limit: 2, null: false
+ t.timestamptz "created_at", default: -> { "now()" }, null: false
+ t.timestamptz "modified_at", default: -> { "now()" }, null: false
+ end
+
+ create_table "rosters", primary_key: "roster_id", id: :integer, default: nil, force: :cascade do |t|
+ t.bigint "league_user_id", null: false
+ t.integer "team_id", limit: 2, null: false
+ t.timestamptz "created_at", default: -> { "now()" }, null: false
+ t.timestamptz "modified_at", default: -> { "now()" }, null: false
+ end
+
+ create_table "scores", primary_key: "score_id", id: :integer, default: nil, force: :cascade do |t|
+ t.integer "season_id", null: false
+ t.integer "team_id", null: false
+ t.integer "week", limit: 2, null: false
+ t.enum "category", default: "win", null: false, enum_type: "score_category"
+ t.timestamptz "scored_at", default: -> { "now()" }, null: false
+ t.timestamptz "created_at", default: -> { "now()" }, null: false
+ t.timestamptz "modified_at", default: -> { "now()" }, null: false
+
+ t.unique_constraint ["season_id", "team_id", "week", "category"], name: "scores_season_id_team_id_week_category_key"
+ end
+
+ create_table "seasons", primary_key: "season_id", id: { type: :integer, limit: 2, default: nil }, force: :cascade do |t|
+ t.timestamptz "started_at", null: false
+ t.timestamptz "ended_at", null: false
+ t.timestamptz "created_at", default: -> { "now()" }, null: false
+ t.timestamptz "modified_at", default: -> { "now()" }, null: false
+ end
+
+ create_table "teams", primary_key: "team_id", id: { type: :integer, limit: 2, default: nil }, force: :cascade do |t|
+ t.text "name", null: false
+ t.enum "division", null: false, enum_type: "divisions"
+ t.text "external_id"
+ t.timestamptz "created_at", default: -> { "now()" }, null: false
+ t.timestamptz "modified_at", default: -> { "now()" }, null: false
+ t.check_constraint "char_length(name) <= 255", name: "teams_name_ck"
+ end
+
+ create_table "users", primary_key: "user_id", id: :integer, default: nil, force: :cascade do |t|
+ t.text "name"
+ t.text "password", null: false
+ t.timestamptz "created_at", default: -> { "now()" }, null: false
+ t.timestamptz "modified_at", default: -> { "now()" }, null: false
+ end
+
+ add_foreign_key "drafts", "league_seasons", primary_key: "league_season_id", name: "drafts_league_seasons_fk"
+ add_foreign_key "league_seasons", "leagues", primary_key: "league_id", name: "league_seasons_leagues_fk"
+ add_foreign_key "league_seasons", "seasons", primary_key: "season_id", name: "league_seasons_seasons_fk"
+ add_foreign_key "league_users", "league_seasons", primary_key: "league_season_id", name: "league_users_league_seasons_fk"
+ add_foreign_key "league_users", "users", primary_key: "user_id", name: "league_users_users_fk"
+ add_foreign_key "leagues", "users", primary_key: "user_id", name: "leagues_users_fk"
+ add_foreign_key "picks", "drafts", primary_key: "draft_id", name: "picks_drafts_fk"
+ add_foreign_key "picks", "league_users", primary_key: "league_user_id", name: "picks_league_users_fk"
+ add_foreign_key "picks", "teams", primary_key: "team_id", name: "picks_teams_fk"
+ add_foreign_key "rankings", "seasons", primary_key: "season_id", name: "rankings_seasons_fk"
+ add_foreign_key "rosters", "league_users", primary_key: "league_user_id", name: "rosters_league_users_fk"
+ add_foreign_key "rosters", "teams", primary_key: "team_id", name: "rosters_teams_fk"
+ add_foreign_key "scores", "seasons", primary_key: "season_id", name: "scores_seasons_fk"
+ add_foreign_key "scores", "teams", primary_key: "team_id", name: "scores_teams_fk"
+end