# encoding: UTF-8
# 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.
#
# Note that this schema.rb definition is the authoritative source for your
# database schema. If you need to create the application database on another
# system, you should be using db:schema:load, not running all the migrations
# from scratch. The latter is a flawed and unsustainable approach (the more migrations
# you'll amass, the slower it'll run and the greater likelihood for issues).
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20210202183522) do

  # These are extensions that must be enabled in order to support this database
  enable_extension "plpgsql"
  enable_extension "fuzzystrmatch"
  enable_extension "pg_trgm"
  enable_extension "uuid-ossp"

  create_table "active_admin_comments", force: :cascade do |t|
    t.string   "resource_id",   limit: 255, null: false
    t.string   "resource_type", limit: 255, null: false
    t.integer  "author_id"
    t.string   "author_type",   limit: 255
    t.text     "body"
    t.datetime "created_at",                null: false
    t.datetime "updated_at",                null: false
    t.string   "namespace",     limit: 255
  end

  add_index "active_admin_comments", ["author_type", "author_id"], name: "index_active_admin_comments_on_author_type_and_author_id", using: :btree
  add_index "active_admin_comments", ["namespace"], name: "index_active_admin_comments_on_namespace", using: :btree
  add_index "active_admin_comments", ["resource_type", "resource_id"], name: "index_admin_comments_on_resource_type_and_resource_id", using: :btree

  create_table "active_music_sessions", force: :cascade do |t|
    t.string   "user_id",                        limit: 64,                     null: false
    t.datetime "created_at",                                  default: "now()", null: false
    t.datetime "updated_at",                                  default: "now()", null: false
    t.string   "claimed_recording_id",           limit: 64
    t.string   "claimed_recording_initiator_id", limit: 64
    t.integer  "track_changes_counter",                       default: 0
    t.string   "jam_track_id",                   limit: 64
    t.string   "jam_track_initiator_id",         limit: 64
    t.string   "backing_track_path",             limit: 1024
    t.string   "backing_track_initiator_id",     limit: 64
    t.boolean  "metronome_active",                            default: false,   null: false
    t.string   "metronome_initiator_id",         limit: 64
    t.integer  "school_id"
    t.boolean  "is_platform_instructor",                      default: false,   null: false
  end

  create_table "affiliate_distributions", force: :cascade do |t|
    t.integer  "affiliate_referral_id",                                        null: false
    t.integer  "affiliate_referral_fee_in_cents",                              null: false
    t.string   "sale_line_item_id",               limit: 64,                   null: false
    t.boolean  "affiliate_refunded",                         default: false,   null: false
    t.datetime "affiliate_refunded_at"
    t.datetime "created_at",                                 default: "now()", null: false
    t.datetime "updated_at",                                 default: "now()", null: false
  end

  create_table "affiliate_legalese", force: :cascade do |t|
    t.text     "legalese"
    t.integer  "version",    default: 1,       null: false
    t.datetime "created_at", default: "now()", null: false
    t.datetime "updated_at", default: "now()", null: false
  end

  create_table "affiliate_monthly_payments", force: :cascade do |t|
    t.integer  "month",                                  null: false
    t.integer  "year",                                   null: false
    t.integer  "affiliate_partner_id",                   null: false
    t.integer  "due_amount_in_cents",  default: 0,       null: false
    t.boolean  "closed",               default: false,   null: false
    t.integer  "jamtracks_sold",       default: 0,       null: false
    t.datetime "closed_at"
    t.datetime "last_updated"
    t.datetime "created_at",           default: "now()", null: false
    t.datetime "updated_at",           default: "now()", null: false
  end

  add_index "affiliate_monthly_payments", ["affiliate_partner_id", "year", "month"], name: "affiliate_monthly_payments_affiliate_partner_id_year_month_idx", using: :btree
  add_index "affiliate_monthly_payments", ["year", "month", "affiliate_partner_id"], name: "affiliate_monthly_payments_year_month_affiliate_partner_id_idx", unique: true, using: :btree

  create_table "affiliate_partners", force: :cascade do |t|
    t.string   "partner_name",                 limit: 1000
    t.string   "partner_user_id",              limit: 64
    t.string   "entity_type",                  limit: 64
    t.string   "legalese_id",                  limit: 64
    t.datetime "signed_at"
    t.datetime "last_paid_at"
    t.json     "address",                                                           default: {},      null: false
    t.string   "tax_identifier",               limit: 1000
    t.integer  "referral_user_count",                                               default: 0,       null: false
    t.integer  "cumulative_earnings_in_cents",                                      default: 0,       null: false
    t.datetime "created_at",                                                        default: "now()", null: false
    t.datetime "updated_at",                                                        default: "now()", null: false
    t.decimal  "rate",                                      precision: 8, scale: 2, default: 0.1
    t.decimal  "lesson_rate",                               precision: 8, scale: 2, default: 0.2,     null: false
    t.string   "special"
  end

  add_index "affiliate_partners", ["legalese_id"], name: "affiliate_partners_legalese_idx", using: :btree
  add_index "affiliate_partners", ["special"], name: "affiliate_partners_special_key", unique: true, using: :btree

  create_table "affiliate_quarterly_payments", force: :cascade do |t|
    t.integer  "quarter",                                null: false
    t.integer  "year",                                   null: false
    t.integer  "affiliate_partner_id",                   null: false
    t.integer  "due_amount_in_cents",  default: 0,       null: false
    t.boolean  "paid",                 default: false,   null: false
    t.boolean  "closed",               default: false,   null: false
    t.integer  "jamtracks_sold",       default: 0,       null: false
    t.datetime "closed_at"
    t.datetime "paid_at"
    t.datetime "last_updated"
    t.datetime "created_at",           default: "now()", null: false
    t.datetime "updated_at",           default: "now()", null: false
  end

  add_index "affiliate_quarterly_payments", ["affiliate_partner_id", "year", "quarter"], name: "affiliate_quarterly_payments_affiliate_partner_id_year_quar_idx", using: :btree
  add_index "affiliate_quarterly_payments", ["year", "quarter", "affiliate_partner_id"], name: "affiliate_quarterly_payments_year_quarter_affiliate_partner_idx", unique: true, using: :btree

  create_table "affiliate_referral_visits", force: :cascade do |t|
    t.integer  "affiliate_partner_id",                              null: false
    t.string   "ip_address",                                        null: false
    t.string   "visited_url"
    t.string   "referral_url"
    t.boolean  "first_visit",                     default: true,    null: false
    t.string   "user_id",              limit: 64
    t.datetime "created_at",                      default: "now()", null: false
  end

  add_index "affiliate_referral_visits", ["affiliate_partner_id", "created_at"], name: "affiliate_referral_visits_affiliate_partner_id_created_at_idx", using: :btree

  create_table "affiliate_traffic_totals", id: false, force: :cascade do |t|
    t.date     "day",                                    null: false
    t.integer  "signups",              default: 0,       null: false
    t.integer  "visits",               default: 0,       null: false
    t.integer  "affiliate_partner_id",                   null: false
    t.datetime "created_at",           default: "now()", null: false
  end

  add_index "affiliate_traffic_totals", ["affiliate_partner_id", "day"], name: "affiliate_traffic_totals_affiliate_partner_id_day_idx", using: :btree
  add_index "affiliate_traffic_totals", ["affiliate_partner_id"], name: "index_affiliate_traffic_totals_on_affiliate_partner_id", using: :btree
  add_index "affiliate_traffic_totals", ["day", "affiliate_partner_id"], name: "affiliate_traffic_totals_day_affiliate_partner_id_idx", unique: true, using: :btree
  add_index "affiliate_traffic_totals", ["day"], name: "index_affiliate_traffic_totals_on_day", using: :btree

  create_table "arses", force: :cascade do |t|
    t.string   "name",        limit: 200,                                                                             null: false
    t.boolean  "active",                                            default: true
    t.datetime "created_at",                                        default: "now()",                                 null: false
    t.datetime "updated_at",                                        default: "now()",                                 null: false
    t.string   "provider",    limit: 20,                            default: "gcp",                                   null: false
    t.integer  "id_int",                                            default: "nextval('arses_id_int_seq'::regclass)", null: false
    t.string   "ip",          limit: 200
    t.string   "username",    limit: 200,                           default: "smoketest"
    t.string   "password",    limit: 200,                           default: "foolishcharmer"
    t.integer  "port",                                              default: 3478
    t.boolean  "beta",                                              default: false
    t.string   "country",     limit: 200
    t.string   "city",        limit: 200
    t.decimal  "latitude",                precision: 15, scale: 10
    t.decimal  "longitude",               precision: 15, scale: 10
    t.string   "subdivision", limit: 200
    t.string   "continent",   limit: 200
  end

  add_index "arses", ["name"], name: "arses_name_key", unique: true, using: :btree

  create_table "artifact_updates", id: false, force: :cascade do |t|
    t.string  "id",          limit: 64,   default: "uuid_generate_v4()", null: false
    t.string  "product",     limit: 255,                                 null: false
    t.string  "version",     limit: 255,                                 null: false
    t.string  "uri",         limit: 2000,                                null: false
    t.string  "sha1",        limit: 255,                                 null: false
    t.string  "environment", limit: 255,  default: "public",             null: false
    t.integer "size",                                                    null: false
  end

  add_index "artifact_updates", ["product", "version"], name: "artifact_updates_uniqkey", unique: true, using: :btree

  create_table "backing_tracks", force: :cascade do |t|
    t.string   "filename",           limit: 1024,                   null: false
    t.string   "connection_id",      limit: 64,                     null: false
    t.string   "client_track_id",    limit: 64,                     null: false
    t.string   "client_resource_id", limit: 100
    t.datetime "created_at",                      default: "now()", null: false
    t.datetime "updated_at",                      default: "now()", null: false
  end

  create_table "band_invitations", force: :cascade do |t|
    t.string   "user_id",    limit: 64
    t.string   "band_id",    limit: 64
    t.boolean  "accepted"
    t.string   "creator_id", limit: 64
    t.datetime "created_at",            default: "now()", null: false
    t.datetime "updated_at",            default: "now()", null: false
  end

  create_table "bands", force: :cascade do |t|
    t.string   "name",                        limit: 1024,                                             null: false
    t.string   "website",                     limit: 4000
    t.string   "biography",                   limit: 4000,                                             null: false
    t.datetime "created_at",                                                         default: "now()", null: false
    t.datetime "updated_at",                                                         default: "now()", null: false
    t.string   "city",                        limit: 100
    t.string   "state",                       limit: 100
    t.string   "country",                     limit: 100
    t.string   "photo_url",                   limit: 2048
    t.string   "logo_url",                    limit: 2048
    t.tsvector "name_tsv"
    t.string   "original_fpfile_photo",       limit: 8000
    t.string   "cropped_fpfile_photo",        limit: 8000
    t.string   "cropped_s3_path_photo",       limit: 512
    t.string   "crop_selection_photo",        limit: 256
    t.decimal  "lat",                                      precision: 15, scale: 10
    t.decimal  "lng",                                      precision: 15, scale: 10
    t.string   "large_photo_url",             limit: 2048
    t.string   "cropped_large_s3_path_photo", limit: 512
    t.string   "cropped_large_fpfile_photo",  limit: 8000
    t.boolean  "did_real_session",                                                   default: false
    t.string   "band_type",                   limit: 16,                             default: ""
    t.string   "band_status",                 limit: 16,                             default: ""
    t.integer  "concert_count",               limit: 2,                              default: 0
    t.boolean  "add_new_members",                                                    default: false
    t.integer  "play_commitment",             limit: 2,                              default: 0
    t.boolean  "touring_option",                                                     default: false
    t.boolean  "paid_gigs",                                                          default: false
    t.boolean  "free_gigs",                                                          default: false
    t.integer  "hourly_rate"
    t.integer  "gig_minimum"
    t.integer  "school_id"
  end

  add_index "bands", ["name_tsv"], name: "bands_name_tsv_index", using: :gin

  create_table "bands_musicians", force: :cascade do |t|
    t.string   "band_id",    limit: 64,                   null: false
    t.string   "user_id",    limit: 64,                   null: false
    t.boolean  "admin",                 default: false,   null: false
    t.datetime "created_at",            default: "now()", null: false
    t.datetime "updated_at",            default: "now()", null: false
  end

  add_index "bands_musicians", ["band_id", "user_id"], name: "band_musician_uniqkey", unique: true, using: :btree
  add_index "bands_musicians", ["user_id"], name: "bands_musicians_user_id_idx", using: :btree

  create_table "broadcast_notification_views", force: :cascade do |t|
    t.string   "user_id",                   limit: 64,                   null: false
    t.string   "broadcast_notification_id", limit: 64,                   null: false
    t.integer  "view_count",                           default: 0
    t.datetime "active_at",                            default: "now()", null: false
    t.datetime "created_at",                           default: "now()", null: false
    t.datetime "updated_at",                           default: "now()", null: false
  end

  add_index "broadcast_notification_views", ["user_id", "broadcast_notification_id"], name: "user_broadcast_idx", using: :btree

  create_table "broadcast_notifications", force: :cascade do |t|
    t.string   "title",        limit: 64
    t.string   "message",      limit: 256
    t.string   "button_label", limit: 32
    t.string   "button_url"
    t.integer  "frequency",                default: 0
    t.datetime "created_at",               default: "now()", null: false
    t.datetime "updated_at",               default: "now()", null: false
  end

  create_table "broadcasts", force: :cascade do |t|
    t.string   "music_session_id", limit: 64,                   null: false
    t.string   "user_id",          limit: 64,                   null: false
    t.string   "broadcast_id",                                  null: false
    t.string   "stream_id"
    t.string   "broadcast_status"
    t.string   "stream_status"
    t.string   "stream_name"
    t.string   "stream_address"
    t.string   "broadcast_data"
    t.string   "stream_data"
    t.datetime "created_at",                  default: "now()", null: false
    t.datetime "updated_at",                  default: "now()", null: false
  end

  add_index "broadcasts", ["broadcast_id"], name: "idx_broadcast_broadcast_id", using: :btree
  add_index "broadcasts", ["broadcast_status"], name: "idx_broadcast_status", using: :btree
  add_index "broadcasts", ["music_session_id"], name: "idx_broadcast_music_session_id", using: :btree
  add_index "broadcasts", ["stream_status"], name: "idx_stream_status", using: :btree

  create_table "calendars", force: :cascade do |t|
    t.string   "user_id",        limit: 64,                     null: false
    t.string   "target_uid",     limit: 64,                     null: false
    t.string   "name",           limit: 128
    t.string   "description",    limit: 8000
    t.boolean  "trigger_delete",              default: false
    t.datetime "start_at",                                      null: false
    t.datetime "end_at",                                        null: false
    t.string   "recurring_mode", limit: 50,   default: "once",  null: false
    t.datetime "created_at",                  default: "now()", null: false
    t.datetime "updated_at",                  default: "now()", null: false
  end

  create_table "campaign_spends", force: :cascade do |t|
    t.string   "campaign",                                             null: false
    t.decimal  "spend",      precision: 8, scale: 2,                   null: false
    t.integer  "month",                                                null: false
    t.integer  "year",                                                 null: false
    t.datetime "created_at",                         default: "now()", null: false
    t.datetime "updated_at",                         default: "now()", null: false
  end

  create_table "charges", force: :cascade do |t|
    t.integer  "amount_in_cents",                                       null: false
    t.integer  "fee_in_cents",                        default: 0,       null: false
    t.string   "type",                    limit: 64,                    null: false
    t.boolean  "sent_billing_notices",                default: false,   null: false
    t.datetime "sent_billing_notices_at"
    t.datetime "last_billing_attempt_at"
    t.boolean  "billed",                              default: false,   null: false
    t.datetime "billed_at"
    t.boolean  "post_processed",                      default: false,   null: false
    t.datetime "post_processed_at"
    t.string   "billing_error_reason"
    t.string   "billing_error_detail"
    t.boolean  "billing_should_retry",                default: true,    null: false
    t.integer  "billing_attempts",                    default: 0,       null: false
    t.string   "stripe_charge_id",        limit: 200
    t.datetime "created_at",                          default: "now()", null: false
    t.datetime "updated_at",                          default: "now()", null: false
    t.string   "user_id",                 limit: 64
  end

  add_index "charges", ["billing_should_retry"], name: "index_charges_on_billing_should_retry", using: :btree
  add_index "charges", ["type"], name: "index_charges_on_type", using: :btree

  create_table "chat_messages", force: :cascade do |t|
    t.string   "user_id",              limit: 64
    t.string   "music_session_id",     limit: 64
    t.text     "message",                                              null: false
    t.datetime "created_at",                       default: "now()",   null: false
    t.string   "channel",              limit: 128, default: "session", null: false
    t.string   "target_user_id",       limit: 64
    t.string   "lesson_session_id",    limit: 64
    t.string   "purpose",              limit: 200
    t.string   "music_notation_id",    limit: 64
    t.string   "claimed_recording_id", limit: 64
  end

  add_index "chat_messages", ["channel"], name: "chat_messages_idx_channels", using: :btree
  add_index "chat_messages", ["created_at"], name: "chat_messages_idx_created_at", using: :btree
  add_index "chat_messages", ["music_session_id"], name: "chat_messages_idx_music_session_id", using: :btree

  create_table "cities", id: false, force: :cascade do |t|
    t.string "city",        limit: 255, null: false
    t.string "region",      limit: 2,   null: false
    t.string "countrycode", limit: 2,   null: false
  end

  create_table "claimed_recordings", force: :cascade do |t|
    t.string   "user_id",           limit: 64,                     null: false
    t.string   "recording_id",      limit: 64,                     null: false
    t.string   "name",              limit: 200,                    null: false
    t.boolean  "is_public",                      default: true,    null: false
    t.string   "genre_id",          limit: 64,                     null: false
    t.datetime "created_at",                     default: "now()", null: false
    t.datetime "updated_at",                     default: "now()", null: false
    t.string   "description",       limit: 8000
    t.tsvector "description_tsv"
    t.tsvector "name_tsv"
    t.boolean  "discarded",                      default: false
    t.boolean  "upload_to_youtube",              default: false,   null: false
  end

  add_index "claimed_recordings", ["description_tsv"], name: "claimed_recordings_description_tsv_index", using: :gin
  add_index "claimed_recordings", ["is_public"], name: "index_claimed_recordings_on_is_public", using: :btree
  add_index "claimed_recordings", ["name_tsv"], name: "claimed_recordings_name_tsv_index", using: :gin
  add_index "claimed_recordings", ["recording_id"], name: "index_claimed_recordings_on_recording_id", using: :btree
  add_index "claimed_recordings", ["user_id", "recording_id"], name: "musician_recording_uniqkey", unique: true, using: :btree

  create_table "client_live_streams", force: :cascade do |t|
    t.string   "user_id",          limit: 64,                   null: false
    t.string   "music_session_id", limit: 64
    t.string   "message"
    t.datetime "created_at",                  default: "now()", null: false
    t.datetime "updated_at",                  default: "now()", null: false
  end

  create_table "cohorts", force: :cascade do |t|
    t.json     "data_set",      default: {},      null: false
    t.datetime "group_start",                     null: false
    t.datetime "group_end",                       null: false
    t.boolean  "all_time",      default: false,   null: false
    t.datetime "monthly_start"
    t.datetime "monthly_end"
    t.datetime "created_at",    default: "now()", null: false
    t.datetime "updated_at",    default: "now()", null: false
  end

  add_index "cohorts", ["group_start"], name: "index_group_date", using: :btree

  create_table "connections", force: :cascade do |t|
    t.string   "user_id",                     limit: 64
    t.string   "client_id",                   limit: 64,                                                                 null: false
    t.datetime "created_at",                              default: "now()",                                              null: false
    t.datetime "updated_at",                              default: "now()",                                              null: false
    t.string   "music_session_id",            limit: 64
    t.string   "ip_address",                  limit: 64,                                                                 null: false
    t.boolean  "as_musician"
    t.string   "aasm_state",                  limit: 64,  default: "idle",                                               null: false
    t.integer  "addr",                        limit: 8,                                                                  null: false
    t.integer  "locidispid",                  limit: 8
    t.datetime "joined_session_at"
    t.string   "client_type",                 limit: 256,                                                                null: false
    t.integer  "stale_time",                              default: 40,                                                   null: false
    t.integer  "expire_time",                             default: 60,                                                   null: false
    t.float    "last_jam_audio_latency"
    t.string   "channel_id",                  limit: 256,                                                                null: false
    t.boolean  "udp_reachable",                           default: true,                                                 null: false
    t.datetime "scoring_timeout",                         default: "now()",                                              null: false
    t.integer  "scoring_failures",                        default: 0,                                                    null: false
    t.integer  "scoring_timeout_occurrences",             default: 0,                                                    null: false
    t.integer  "scoring_failures_offset",                 default: 0,                                                    null: false
    t.string   "gateway",                                 default: "default-1",                                          null: false
    t.boolean  "is_network_testing",                      default: false,                                                null: false
    t.boolean  "metronome_open",                          default: false,                                                null: false
    t.boolean  "user_active",                             default: true
    t.boolean  "is_jamblaster",                           default: false
    t.string   "client_role"
    t.string   "parent_client_id"
    t.integer  "client_id_int",                           default: "nextval('connections_client_id_int_seq'::regclass)", null: false
  end

  add_index "connections", ["client_id"], name: "connections_client_id_key", unique: true, using: :btree
  add_index "connections", ["locidispid"], name: "connections_locidispid_ndx", using: :btree

  create_table "countries", id: false, force: :cascade do |t|
    t.string "countrycode", limit: 2,  null: false
    t.string "countryname", limit: 64
  end

  create_table "crash_dumps", force: :cascade do |t|
    t.string   "client_type",    limit: 64,                      null: false
    t.string   "client_id",      limit: 64
    t.string   "user_id",        limit: 64
    t.string   "session_id",     limit: 64
    t.datetime "timestamp"
    t.string   "uri",            limit: 1000
    t.datetime "created_at",                   default: "now()", null: false
    t.datetime "updated_at",                   default: "now()", null: false
    t.string   "client_version", limit: 100,                     null: false
    t.string   "description",    limit: 20000
    t.string   "crash_context",  limit: 10000
    t.string   "fsize",          limit: 10000
  end

  add_index "crash_dumps", ["client_id"], name: "crash_dumps_client_id_idx", using: :btree
  add_index "crash_dumps", ["timestamp"], name: "crash_dumps_timestamp_idx", using: :btree
  add_index "crash_dumps", ["user_id"], name: "crash_dumps_user_id_idx", using: :btree

  create_table "current_network_scores", id: false, force: :cascade do |t|
    t.integer  "alocidispid", limit: 8, null: false
    t.integer  "blocidispid", limit: 8, null: false
    t.integer  "score",                 null: false
    t.boolean  "limited",               null: false
    t.datetime "score_dt",              null: false
  end

  add_index "current_network_scores", ["alocidispid", "blocidispid"], name: "current_network_scores_a_b_ndx", unique: true, using: :btree
  add_index "current_network_scores", ["blocidispid", "alocidispid"], name: "current_network_scores_b_a_ndx", unique: true, using: :btree

  create_table "diagnostics", id: false, force: :cascade do |t|
    t.string   "id",         limit: 64,  default: "uuid_generate_v4()", null: false
    t.string   "user_id",    limit: 64,                                 null: false
    t.string   "type",       limit: 255,                                null: false
    t.string   "creator",    limit: 255,                                null: false
    t.text     "data"
    t.datetime "created_at",             default: "now()",              null: false
  end

  add_index "diagnostics", ["type"], name: "diagnostics_type_idx", using: :btree
  add_index "diagnostics", ["user_id"], name: "diagnostics_user_id", using: :btree

  create_table "download_trackers", force: :cascade do |t|
    t.string   "user_id",      limit: 64
    t.string   "remote_ip",    limit: 400,                    null: false
    t.string   "jam_track_id", limit: 64,                     null: false
    t.boolean  "paid",                      default: false,   null: false
    t.datetime "created_at",                default: "now()", null: false
    t.string   "fingerprint",  limit: 1000
    t.boolean  "is_client",                 default: false
  end

  add_index "download_trackers", ["created_at", "paid"], name: "index_download_trackers_on_created_at", using: :btree
  add_index "download_trackers", ["fingerprint"], name: "index_download_trackers_on_fingerprint", using: :btree
  add_index "download_trackers", ["remote_ip"], name: "index_download_trackers_on_remote_ip", using: :btree
  add_index "download_trackers", ["user_id"], name: "index_download_trackers_on_user_id", using: :btree

  create_table "email_batch_sets", force: :cascade do |t|
    t.string   "email_batch_id", limit: 64
    t.datetime "started_at"
    t.text     "user_ids",                  default: "",      null: false
    t.integer  "batch_count"
    t.datetime "created_at",                default: "now()", null: false
    t.datetime "updated_at",                default: "now()", null: false
    t.integer  "trigger_index",             default: 0,       null: false
    t.string   "sub_type",       limit: 64
    t.string   "user_id",        limit: 64
  end

  add_index "email_batch_sets", ["email_batch_id", "started_at"], name: "email_batch_set_uniqkey", unique: true, using: :btree
  add_index "email_batch_sets", ["email_batch_id"], name: "email_batch_set_fkidx", using: :btree
  add_index "email_batch_sets", ["user_id", "sub_type"], name: "email_batch_sets_progress_idx", using: :btree

  create_table "email_batches", force: :cascade do |t|
    t.string   "subject",      limit: 256
    t.text     "body"
    t.string   "from_email",   limit: 64,  default: "JamKazam <noreply@jamkazam.com>", null: false
    t.string   "aasm_state",   limit: 32,  default: "pending",                         null: false
    t.text     "test_emails",              default: "test@jamkazam.com",               null: false
    t.integer  "opt_in_count",             default: 0,                                 null: false
    t.integer  "sent_count",               default: 0,                                 null: false
    t.integer  "lock_version"
    t.datetime "started_at"
    t.datetime "completed_at"
    t.datetime "created_at",               default: "now()",                           null: false
    t.datetime "updated_at",               default: "now()",                           null: false
    t.string   "type",         limit: 64,  default: "JamRuby::EmailBatch",             null: false
    t.string   "sub_type",     limit: 64
  end

  create_table "email_blacklists", force: :cascade do |t|
    t.string   "email",      limit: 1000,                   null: false
    t.string   "source",     limit: 1000
    t.string   "notes",      limit: 1000
    t.datetime "created_at",              default: "now()", null: false
    t.datetime "updated_at",              default: "now()", null: false
  end

  add_index "email_blacklists", ["email"], name: "email_blacklists_email_key", unique: true, using: :btree

  create_table "email_errors", force: :cascade do |t|
    t.string   "user_id",       limit: 64
    t.string   "error_type",    limit: 32
    t.string   "email_address", limit: 256
    t.string   "status",        limit: 32
    t.datetime "email_date",                default: "now()"
    t.text     "reason"
    t.datetime "created_at",                default: "now()", null: false
    t.datetime "updated_at",                default: "now()", null: false
  end

  add_index "email_errors", ["email_address"], name: "email_error_address_idx", using: :btree
  add_index "email_errors", ["user_id"], name: "email_error_user_fkidx", using: :btree

  create_table "event_brite_order_uploads", force: :cascade do |t|
    t.string   "upload_file_name", limit: 500,                   null: false
    t.datetime "created_at",                   default: "now()", null: false
    t.datetime "updated_at",                   default: "now()", null: false
  end

  create_table "event_brite_orders", force: :cascade do |t|
    t.string   "live_stream_id",              limit: 64
    t.string   "event_brite_order_upload_id", limit: 64
    t.string   "event_name",                  limit: 100,                   null: false
    t.string   "order_id",                    limit: 100,                   null: false
    t.integer  "ticket_count"
    t.string   "ticket_type",                 limit: 100
    t.string   "first_name",                  limit: 100
    t.string   "last_name",                   limit: 100
    t.string   "email",                       limit: 200
    t.datetime "created_at",                              default: "now()", null: false
    t.datetime "updated_at",                              default: "now()", null: false
    t.integer  "times_claimed",                           default: 0,       null: false
  end

  add_index "event_brite_orders", ["order_id"], name: "event_brite_orders_order_id_key", unique: true, using: :btree

  create_table "event_sessions", force: :cascade do |t|
    t.datetime "starts_at"
    t.datetime "ends_at"
    t.string   "pinned_state", limit: 255
    t.string   "img_url",      limit: 1024
    t.integer  "img_width"
    t.integer  "img_height"
    t.string   "event_id",     limit: 64
    t.string   "user_id",      limit: 64
    t.string   "band_id",      limit: 64
    t.datetime "created_at",                default: "now()", null: false
    t.datetime "updated_at",                default: "now()", null: false
    t.integer  "ordinal"
  end

  create_table "events", force: :cascade do |t|
    t.string   "slug",               limit: 512,                   null: false
    t.text     "title"
    t.text     "description"
    t.boolean  "show_sponser",                   default: false,   null: false
    t.datetime "created_at",                     default: "now()", null: false
    t.datetime "updated_at",                     default: "now()", null: false
    t.text     "social_description"
  end

  add_index "events", ["slug"], name: "events_slug_key", unique: true, using: :btree

  create_table "facebook_signups", force: :cascade do |t|
    t.string   "lookup_id",        limit: 255,                    null: false
    t.string   "last_name",        limit: 100
    t.string   "first_name",       limit: 100
    t.string   "gender",           limit: 1
    t.string   "email",            limit: 1024
    t.string   "uid",              limit: 1024
    t.string   "token",            limit: 1024
    t.datetime "token_expires_at"
    t.datetime "created_at",                    default: "now()", null: false
    t.datetime "updated_at",                    default: "now()", null: false
  end

  add_index "facebook_signups", ["lookup_id"], name: "facebook_signups_lookup_id_key", unique: true, using: :btree

  create_table "fan_invitations", force: :cascade do |t|
    t.string   "sender_id",        limit: 64
    t.string   "receiver_id",      limit: 64
    t.string   "music_session_id", limit: 64
    t.datetime "created_at",                  default: "now()", null: false
    t.datetime "updated_at",                  default: "now()", null: false
  end

  create_table "feeds", id: :bigserial, force: :cascade do |t|
    t.string   "recording_id",           limit: 64
    t.string   "music_session_id",       limit: 64
    t.datetime "created_at",                        default: "now()", null: false
    t.datetime "updated_at",                        default: "now()", null: false
    t.boolean  "active",                            default: false
    t.integer  "school_id"
    t.boolean  "is_platform_instructor",            default: false,   null: false
  end

  add_index "feeds", ["music_session_id"], name: "feeds_music_session_id_key", unique: true, using: :btree
  add_index "feeds", ["recording_id"], name: "feeds_recording_id_key", unique: true, using: :btree
  add_index "feeds", ["school_id"], name: "feeds_schood_id_idx", using: :btree

  create_table "fingerprint_whitelists", force: :cascade do |t|
    t.string "fingerprint", limit: 20000, null: false
  end

  add_index "fingerprint_whitelists", ["fingerprint"], name: "fingerprint_whitelists_fingerprint_key", unique: true, using: :btree

  create_table "follows", force: :cascade do |t|
    t.string   "user_id",         limit: 64,                   null: false
    t.string   "followable_id",   limit: 64,                   null: false
    t.string   "followable_type", limit: 25,                   null: false
    t.datetime "created_at",                 default: "now()", null: false
    t.datetime "updated_at",                 default: "now()", null: false
  end

  add_index "follows", ["user_id", "followable_id"], name: "follows_user_uniqkey", unique: true, using: :btree

  create_table "fraud_alerts", force: :cascade do |t|
    t.string   "machine_fingerprint_id", limit: 64,                   null: false
    t.string   "user_id",                limit: 64,                   null: false
    t.boolean  "resolved",                          default: false,   null: false
    t.datetime "created_at",                        default: "now()", null: false
  end

  create_table "friend_requests", force: :cascade do |t|
    t.string   "user_id",    limit: 64
    t.string   "friend_id",  limit: 64
    t.datetime "created_at",              default: "now()", null: false
    t.datetime "updated_at",              default: "now()", null: false
    t.string   "status",     limit: 50
    t.string   "message",    limit: 4000
  end

  create_table "friendships", force: :cascade do |t|
    t.string   "user_id",    limit: 64
    t.string   "friend_id",  limit: 64
    t.datetime "created_at",            default: "now()", null: false
    t.datetime "updated_at",            default: "now()", null: false
  end

  add_index "friendships", ["user_id", "friend_id"], name: "user_friend_uniqkey", unique: true, using: :btree

  create_table "generic_state", force: :cascade do |t|
    t.datetime "score_history_last_imported_at"
    t.string   "env",                            limit: 255,    default: "development",                       null: false
    t.datetime "affiliate_tallied_at"
    t.date     "bounce_check_at"
    t.string   "top_message",                    limit: 100000
    t.string   "event_page_top_logo_url",        limit: 100000, default: "/assets/event/eventbrite-logo.png"
    t.string   "connection_policy"
  end

  create_table "genre_players", force: :cascade do |t|
    t.string   "player_id",   limit: 64,                      null: false
    t.string   "genre_id",    limit: 64,                      null: false
    t.datetime "created_at",              default: "now()",   null: false
    t.datetime "updated_at",              default: "now()",   null: false
    t.string   "player_type", limit: 128
    t.string   "genre_type",  limit: 20,  default: "profile"
  end

  add_index "genre_players", ["player_id", "player_type", "genre_id", "genre_type"], name: "genre_player_uniqkey", unique: true, using: :btree

  create_table "genres", force: :cascade do |t|
    t.string   "description", limit: 1024,                   null: false
    t.datetime "created_at",               default: "now()", null: false
    t.datetime "updated_at",               default: "now()", null: false
  end

  create_table "genres_jam_tracks", force: :cascade do |t|
    t.string   "jam_track_id", limit: 64,                   null: false
    t.string   "genre_id",     limit: 64,                   null: false
    t.datetime "created_at",              default: "now()", null: false
    t.datetime "updated_at",              default: "now()", null: false
  end

  create_table "genres_music_sessions", force: :cascade do |t|
    t.string "genre_id",         limit: 64
    t.string "music_session_id", limit: 64
  end

  create_table "geoipblocks", id: false, force: :cascade do |t|
    t.integer "beginip", limit: 8, null: false
    t.integer "endip",   limit: 8, null: false
    t.integer "locid",             null: false
  end

  create_table "geoipisp", id: false, force: :cascade do |t|
    t.integer "beginip", limit: 8,  null: false
    t.integer "endip",   limit: 8,  null: false
    t.string  "company", limit: 50, null: false
  end

  add_index "geoipisp", ["company"], name: "geoipisp_company_ndx", using: :btree

  create_table "geoiplocations", primary_key: "locid", force: :cascade do |t|
    t.string  "countrycode", limit: 2
    t.string  "region",      limit: 2
    t.string  "city",        limit: 255
    t.string  "postalcode",  limit: 8
    t.float   "latitude",                null: false
    t.float   "longitude",               null: false
    t.integer "metrocode"
    t.string  "areacode",    limit: 3
  end

  create_table "gift_card_purchases", force: :cascade do |t|
    t.string   "user_id",                        limit: 64,                    null: false
    t.string   "gift_card_type_id",              limit: 64
    t.string   "recurly_adjustment_uuid",        limit: 500
    t.string   "recurly_adjustment_credit_uuid", limit: 500
    t.datetime "created_at",                                 default: "now()", null: false
    t.datetime "updated_at",                                 default: "now()", null: false
  end

  create_table "gift_card_types", force: :cascade do |t|
    t.string   "card_type",  limit: 64,                   null: false
    t.datetime "created_at",            default: "now()", null: false
    t.datetime "updated_at",            default: "now()", null: false
  end

  create_table "gift_cards", force: :cascade do |t|
    t.string   "code",       limit: 64,                    null: false
    t.string   "user_id",    limit: 64
    t.string   "card_type",  limit: 64,                    null: false
    t.string   "origin",     limit: 200
    t.datetime "created_at",             default: "now()", null: false
    t.datetime "updated_at",             default: "now()", null: false
  end

  add_index "gift_cards", ["code"], name: "gift_cards_code_key", unique: true, using: :btree
  add_index "gift_cards", ["user_id"], name: "gift_card_user_id_idx", using: :btree

  create_table "icecast_admin_authentications", force: :cascade do |t|
    t.string   "source_pass", limit: 64,                   null: false
    t.string   "relay_user",  limit: 64,                   null: false
    t.string   "relay_pass",  limit: 64,                   null: false
    t.string   "admin_user",  limit: 64,                   null: false
    t.string   "admin_pass",  limit: 64,                   null: false
    t.datetime "created_at",             default: "now()", null: false
    t.datetime "updated_at",             default: "now()", null: false
  end

  create_table "icecast_directories", force: :cascade do |t|
    t.integer  "yp_url_timeout",              default: 15,      null: false
    t.string   "yp_url",         limit: 1024,                   null: false
    t.datetime "created_at",                  default: "now()", null: false
    t.datetime "updated_at",                  default: "now()", null: false
  end

  create_table "icecast_limits", force: :cascade do |t|
    t.integer  "clients",        default: 1000,    null: false
    t.integer  "sources",        default: 50,      null: false
    t.integer  "queue_size",     default: 102400,  null: false
    t.integer  "client_timeout", default: 30
    t.integer  "header_timeout", default: 15
    t.integer  "source_timeout", default: 10
    t.integer  "burst_size",     default: 65536
    t.datetime "created_at",     default: "now()", null: false
    t.datetime "updated_at",     default: "now()", null: false
  end

  create_table "icecast_listen_sockets", force: :cascade do |t|
    t.integer  "port",                          default: 8001,    null: false
    t.string   "bind_address",     limit: 1024
    t.string   "shoutcast_mount",  limit: 1024
    t.integer  "shoutcast_compat"
    t.datetime "created_at",                    default: "now()", null: false
    t.datetime "updated_at",                    default: "now()", null: false
  end

  create_table "icecast_loggings", force: :cascade do |t|
    t.string   "access_log",   limit: 1024, default: "access.log", null: false
    t.string   "error_log",    limit: 1024, default: "error.log",  null: false
    t.string   "playlist_log", limit: 1024
    t.integer  "log_level",                 default: 3,            null: false
    t.integer  "log_archive"
    t.integer  "log_size",                  default: 10000
    t.datetime "created_at",                default: "now()",      null: false
    t.datetime "updated_at",                default: "now()",      null: false
  end

  create_table "icecast_master_server_relays", force: :cascade do |t|
    t.string   "master_server",          limit: 1024,                   null: false
    t.integer  "master_server_port",                  default: 8001,    null: false
    t.integer  "master_update_interval",              default: 120,     null: false
    t.string   "master_username",        limit: 64,                     null: false
    t.string   "master_pass",            limit: 64,                     null: false
    t.integer  "relays_on_demand",                    default: 1,       null: false
    t.datetime "created_at",                          default: "now()", null: false
    t.datetime "updated_at",                          default: "now()", null: false
  end

  create_table "icecast_mount_templates", force: :cascade do |t|
    t.string   "name",                  limit: 256,                          null: false
    t.string   "source_username",       limit: 64
    t.string   "source_pass",           limit: 64
    t.integer  "max_listeners",                       default: 4
    t.integer  "max_listener_duration",               default: 3600
    t.string   "dump_file",             limit: 1024
    t.string   "intro",                 limit: 1024
    t.string   "fallback_mount",        limit: 1024
    t.integer  "fallback_override",                   default: 1
    t.integer  "fallback_when_full",                  default: 1
    t.string   "charset",               limit: 1024,  default: "ISO8859-1"
    t.integer  "is_public",                           default: 0
    t.string   "stream_name",           limit: 1024
    t.string   "stream_description",    limit: 10000
    t.string   "stream_url",            limit: 1024
    t.string   "genre",                 limit: 256
    t.integer  "bitrate"
    t.string   "mime_type",             limit: 64,    default: "audio/mpeg", null: false
    t.string   "subtype",               limit: 64
    t.integer  "burst_size"
    t.integer  "mp3_metadata_interval"
    t.integer  "hidden",                              default: 1
    t.string   "on_connect",            limit: 1024
    t.string   "on_disconnect",         limit: 1024
    t.string   "authentication_id",     limit: 64,                           null: false
    t.datetime "created_at",                          default: "now()",      null: false
    t.datetime "updated_at",                          default: "now()",      null: false
  end

  create_table "icecast_mounts", force: :cascade do |t|
    t.string   "name",                      limit: 1024,                        null: false
    t.string   "source_username",           limit: 64
    t.string   "source_pass",               limit: 64
    t.integer  "max_listeners",                           default: 4
    t.integer  "max_listener_duration",                   default: 3600
    t.string   "dump_file",                 limit: 1024
    t.string   "intro",                     limit: 1024
    t.string   "fallback_mount",            limit: 1024
    t.integer  "fallback_override",                       default: 1
    t.integer  "fallback_when_full",                      default: 1
    t.string   "charset",                   limit: 1024,  default: "ISO8859-1"
    t.integer  "is_public",                               default: 0
    t.string   "stream_name",               limit: 1024
    t.string   "stream_description",        limit: 10000
    t.string   "stream_url",                limit: 1024
    t.string   "genre",                     limit: 256
    t.integer  "bitrate"
    t.string   "mime_type",                 limit: 64
    t.string   "subtype",                   limit: 64
    t.integer  "burst_size"
    t.integer  "mp3_metadata_interval"
    t.integer  "hidden",                                  default: 1
    t.string   "on_connect",                limit: 1024
    t.string   "on_disconnect",             limit: 1024
    t.string   "authentication_id",         limit: 64
    t.integer  "listeners",                               default: 0,           null: false
    t.boolean  "sourced",                                 default: false,       null: false
    t.datetime "created_at",                              default: "now()",     null: false
    t.datetime "updated_at",                              default: "now()",     null: false
    t.string   "music_session_id",          limit: 64
    t.string   "icecast_server_id",         limit: 64,                          null: false
    t.string   "icecast_mount_template_id", limit: 64
    t.datetime "sourced_needs_changing_at"
    t.boolean  "source_direction",                        default: false,       null: false
  end

  add_index "icecast_mounts", ["name"], name: "icecast_mounts_name_key", unique: true, using: :btree

  create_table "icecast_paths", force: :cascade do |t|
    t.string   "base_dir",     limit: 1024, default: "./",            null: false
    t.string   "log_dir",      limit: 1024, default: "./logs",        null: false
    t.string   "pid_file",     limit: 1024, default: "./icecast.pid"
    t.string   "web_root",     limit: 1024, default: "./web",         null: false
    t.string   "admin_root",   limit: 1024, default: "./admin",       null: false
    t.string   "allow_ip",     limit: 1024
    t.string   "deny_ip",      limit: 1024
    t.string   "alias_source", limit: 1024
    t.string   "alias_dest",   limit: 1024
    t.datetime "created_at",                default: "now()",         null: false
    t.datetime "updated_at",                default: "now()",         null: false
  end

  create_table "icecast_relays", force: :cascade do |t|
    t.string   "server",                   limit: 1024,                   null: false
    t.integer  "port",                                  default: 8001,    null: false
    t.string   "mount",                    limit: 1024,                   null: false
    t.string   "local_mount",              limit: 1024
    t.string   "relay_username",           limit: 64
    t.string   "relay_pass",               limit: 64
    t.integer  "relay_shoutcast_metadata",              default: 0
    t.integer  "on_demand",                             default: 1
    t.datetime "created_at",                            default: "now()", null: false
    t.datetime "updated_at",                            default: "now()", null: false
  end

  create_table "icecast_securities", force: :cascade do |t|
    t.integer  "chroot",                        default: 0,       null: false
    t.string   "change_owner_user",  limit: 64
    t.string   "change_owner_group", limit: 64
    t.datetime "created_at",                    default: "now()", null: false
    t.datetime "updated_at",                    default: "now()", null: false
  end

  create_table "icecast_server_groups", force: :cascade do |t|
    t.string "name", limit: 255, null: false
  end

  add_index "icecast_server_groups", ["name"], name: "icecast_server_groups_name_key", unique: true, using: :btree

  create_table "icecast_server_mounts", force: :cascade do |t|
    t.string   "icecast_mount_id",  limit: 64
    t.string   "icecast_server_id", limit: 64
    t.datetime "created_at",                   default: "now()", null: false
    t.datetime "updated_at",                   default: "now()", null: false
  end

  add_index "icecast_server_mounts", ["icecast_mount_id", "icecast_server_id"], name: "server_mount_uniqkey", unique: true, using: :btree

  create_table "icecast_server_relays", force: :cascade do |t|
    t.string   "icecast_relay_id",  limit: 64
    t.string   "icecast_server_id", limit: 64
    t.datetime "created_at",                   default: "now()", null: false
    t.datetime "updated_at",                   default: "now()", null: false
  end

  add_index "icecast_server_relays", ["icecast_relay_id", "icecast_server_id"], name: "server_relay_uniqkey", unique: true, using: :btree

  create_table "icecast_server_sockets", force: :cascade do |t|
    t.string   "icecast_listen_socket_id", limit: 64
    t.string   "icecast_server_id",        limit: 64
    t.datetime "created_at",                          default: "now()", null: false
    t.datetime "updated_at",                          default: "now()", null: false
  end

  add_index "icecast_server_sockets", ["icecast_listen_socket_id", "icecast_server_id"], name: "server_socket_uniqkey", unique: true, using: :btree

  create_table "icecast_servers", force: :cascade do |t|
    t.integer  "config_changed",                       default: 0
    t.string   "limit_id",                limit: 64
    t.string   "admin_auth_id",           limit: 64
    t.string   "directory_id",            limit: 64
    t.string   "master_relay_id",         limit: 64
    t.string   "path_id",                 limit: 64
    t.string   "logging_id",              limit: 64
    t.string   "security_id",             limit: 64
    t.string   "template_id",             limit: 64,                       null: false
    t.string   "hostname",                limit: 1024,                     null: false
    t.string   "server_id",               limit: 1024,                     null: false
    t.string   "location",                limit: 1024
    t.string   "admin_email",             limit: 1024
    t.integer  "fileserve"
    t.datetime "created_at",                           default: "now()",   null: false
    t.datetime "updated_at",                           default: "now()",   null: false
    t.string   "icecast_server_group_id", limit: 64,   default: "default", null: false
    t.string   "mount_template_id",       limit: 64
    t.datetime "config_updated_at"
  end

  add_index "icecast_servers", ["server_id"], name: "icecast_servers_server_id_key", unique: true, using: :btree

  create_table "icecast_source_changes", force: :cascade do |t|
    t.boolean  "source_direction",                              null: false
    t.string   "change_type",      limit: 64,                   null: false
    t.string   "user_id",          limit: 64
    t.string   "client_id",        limit: 64
    t.boolean  "success",                                       null: false
    t.string   "reason"
    t.string   "detail"
    t.datetime "created_at",                  default: "now()", null: false
    t.string   "icecast_mount_id", limit: 64,                   null: false
  end

  create_table "icecast_template_sockets", force: :cascade do |t|
    t.string   "icecast_listen_socket_id", limit: 64
    t.string   "icecast_template_id",      limit: 64
    t.datetime "created_at",                          default: "now()", null: false
    t.datetime "updated_at",                          default: "now()", null: false
  end

  add_index "icecast_template_sockets", ["icecast_listen_socket_id", "icecast_template_id"], name: "template_socket_uniqkey", unique: true, using: :btree

  create_table "icecast_templates", force: :cascade do |t|
    t.string   "limit_id",        limit: 64
    t.string   "admin_auth_id",   limit: 64
    t.string   "directory_id",    limit: 64
    t.string   "master_relay_id", limit: 64
    t.string   "path_id",         limit: 64
    t.string   "logging_id",      limit: 64
    t.string   "security_id",     limit: 64
    t.string   "location",        limit: 1024,                                null: false
    t.string   "name",            limit: 256,                                 null: false
    t.string   "admin_email",     limit: 1024, default: "admin@jamkazam.com", null: false
    t.integer  "fileserve",                    default: 1,                    null: false
    t.datetime "created_at",                   default: "now()",              null: false
    t.datetime "updated_at",                   default: "now()",              null: false
  end

  create_table "icecast_user_authentications", force: :cascade do |t|
    t.string   "authentication_type",   limit: 16,   default: "url"
    t.string   "filename",              limit: 1024
    t.integer  "allow_duplicate_users"
    t.string   "mount_add",             limit: 1024
    t.string   "mount_remove",          limit: 1024
    t.string   "listener_add",          limit: 1024
    t.string   "listener_remove",       limit: 1024
    t.string   "unused_username",       limit: 64
    t.string   "unused_pass",           limit: 64
    t.string   "auth_header",           limit: 64,   default: "icecast-auth-user: 1"
    t.string   "timelimit_header",      limit: 64,   default: "icecast-auth-timelimit:"
    t.datetime "created_at",                         default: "now()",                   null: false
    t.datetime "updated_at",                         default: "now()",                   null: false
  end

  create_table "init_structures", force: :cascade do |t|
  end

  create_table "instruments", force: :cascade do |t|
    t.string   "description", limit: 1024,                   null: false
    t.datetime "created_at",               default: "now()", null: false
    t.datetime "updated_at",               default: "now()", null: false
    t.integer  "popularity",               default: 0,       null: false
  end

  create_table "invitations", force: :cascade do |t|
    t.string   "sender_id",        limit: 64
    t.string   "receiver_id",      limit: 64
    t.string   "music_session_id", limit: 64
    t.datetime "created_at",                  default: "now()", null: false
    t.datetime "updated_at",                  default: "now()", null: false
    t.string   "join_request_id",  limit: 64
  end

  add_index "invitations", ["music_session_id"], name: "index_invitations_on_music_session_id", using: :btree
  add_index "invitations", ["receiver_id"], name: "index_invitations_on_receiver_id", using: :btree

  create_table "invited_users", force: :cascade do |t|
    t.string   "sender_id",       limit: 64
    t.boolean  "autofriend",                                    null: false
    t.string   "email",           limit: 256
    t.string   "invitation_code", limit: 256,                   null: false
    t.boolean  "accepted",                    default: false
    t.text     "note"
    t.datetime "created_at",                  default: "now()", null: false
    t.datetime "updated_at",                  default: "now()", null: false
    t.string   "invite_medium",   limit: 64
    t.string   "receiver_id",     limit: 64
  end

  add_index "invited_users", ["invitation_code"], name: "invited_users_invitation_code_key", unique: true, using: :btree

  create_table "ip_blacklists", force: :cascade do |t|
    t.string   "remote_ip",  limit: 400,                   null: false
    t.string   "notes"
    t.datetime "created_at",             default: "now()", null: false
    t.datetime "updated_at",             default: "now()", null: false
  end

  add_index "ip_blacklists", ["remote_ip"], name: "ip_blacklists_remote_ip_key", unique: true, using: :btree

  create_table "ip_whitelists", force: :cascade do |t|
    t.string   "remote_ip",  limit: 400,                   null: false
    t.string   "notes"
    t.datetime "created_at",             default: "now()", null: false
    t.datetime "updated_at",             default: "now()", null: false
  end

  add_index "ip_whitelists", ["remote_ip"], name: "ip_whitelists_remote_ip_key", unique: true, using: :btree

  create_table "isp_score_batch", force: :cascade do |t|
    t.text     "json_scoring_data",                   null: false
    t.datetime "created_at",        default: "now()", null: false
  end

  create_table "jam_class_reports", id: false, force: :cascade do |t|
    t.date    "cohort"
    t.string  "campaign"
    t.decimal "spend",                precision: 8, scale: 2
    t.integer "registrations"
    t.integer "td_customers"
    t.decimal "jamclass_rev",         precision: 8, scale: 2
    t.integer "td4"
    t.integer "td2"
    t.integer "td1"
    t.decimal "spend_td",             precision: 8, scale: 2
    t.decimal "purchases0",           precision: 8, scale: 2
    t.decimal "purchases1",           precision: 8, scale: 2
    t.decimal "purchases2",           precision: 8, scale: 2
    t.decimal "purchases3",           precision: 8, scale: 2
    t.decimal "purchases_rest",       precision: 8, scale: 2
    t.integer "purchases0_count"
    t.integer "purchases1_count"
    t.integer "purchases2_count"
    t.integer "purchases3_count"
    t.integer "purchases_rest_count"
    t.integer "purchases_count"
  end

  create_table "jam_track_files", force: :cascade do |t|
    t.string   "jam_track_id",      limit: 64
    t.string   "file_type",                                      null: false
    t.string   "original_filename",                              null: false
    t.integer  "precount_num"
    t.string   "url"
    t.string   "md5"
    t.integer  "length",            limit: 8
    t.datetime "created_at",                   default: "now()", null: false
    t.datetime "updated_at",                   default: "now()", null: false
  end

  create_table "jam_track_hfa_request_ids", force: :cascade do |t|
    t.string   "jam_track_id",             limit: 64,                   null: false
    t.integer  "jam_track_hfa_request_id"
    t.integer  "request_id"
    t.datetime "created_at",                          default: "now()", null: false
    t.datetime "updated_at",                          default: "now()", null: false
  end

  create_table "jam_track_hfa_requests", force: :cascade do |t|
    t.string   "name",                                    null: false
    t.string   "request_csv_filename"
    t.string   "response_csv_filename"
    t.datetime "created_at",            default: "now()", null: false
    t.datetime "updated_at",            default: "now()", null: false
    t.datetime "approved_at"
    t.datetime "received_at"
  end

  create_table "jam_track_licensors", force: :cascade do |t|
    t.string   "name",                             null: false
    t.text     "description"
    t.text     "attention"
    t.string   "address_line_1"
    t.string   "address_line_2"
    t.string   "city"
    t.string   "state"
    t.string   "zip_code"
    t.string   "contact"
    t.string   "email"
    t.string   "phone"
    t.datetime "created_at",     default: "now()", null: false
    t.datetime "updated_at",     default: "now()", null: false
    t.string   "slug"
  end

  add_index "jam_track_licensors", ["name"], name: "jam_track_licensors_name_key", unique: true, using: :btree
  add_index "jam_track_licensors", ["slug"], name: "jam_track_licensors_slug_key", unique: true, using: :btree

  create_table "jam_track_mixdown_packages", force: :cascade do |t|
    t.string   "jam_track_mixdown_id",   limit: 64,                     null: false
    t.string   "file_type",                                             null: false
    t.integer  "sample_rate",                                           null: false
    t.string   "url",                    limit: 2048
    t.string   "md5"
    t.integer  "length"
    t.boolean  "downloaded_since_sign",               default: false,   null: false
    t.datetime "last_step_at"
    t.datetime "last_signed_at"
    t.integer  "download_count",                      default: 0,       null: false
    t.datetime "signed_at"
    t.datetime "downloaded_at"
    t.datetime "signing_queued_at"
    t.integer  "error_count",                         default: 0,       null: false
    t.string   "error_reason"
    t.string   "error_detail"
    t.boolean  "should_retry",                        default: false,   null: false
    t.integer  "packaging_steps"
    t.integer  "current_packaging_step"
    t.string   "private_key"
    t.boolean  "signed"
    t.datetime "signing_started_at"
    t.datetime "first_downloaded"
    t.boolean  "signing",                             default: false,   null: false
    t.string   "encrypt_type"
    t.datetime "first_downloaded_at"
    t.datetime "last_downloaded_at"
    t.string   "version",                             default: "1",     null: false
    t.datetime "created_at",                          default: "now()", null: false
    t.datetime "updated_at",                          default: "now()", null: false
    t.datetime "last_errored_at"
    t.boolean  "queued",                              default: false
    t.boolean  "speed_pitched",                       default: false
  end

  add_index "jam_track_mixdown_packages", ["queued"], name: "jam_track_mixdown_packages_queued", using: :btree
  add_index "jam_track_mixdown_packages", ["signing_queued_at"], name: "jam_track_mixdown_packages_signing_queued", using: :btree
  add_index "jam_track_mixdown_packages", ["updated_at"], name: "jam_track_mixdown_packages_updated", using: :btree

  create_table "jam_track_mixdowns", force: :cascade do |t|
    t.string   "jam_track_id", limit: 64,                     null: false
    t.string   "user_id",      limit: 64,                     null: false
    t.json     "settings",                                    null: false
    t.string   "name",         limit: 1000,                   null: false
    t.string   "description",  limit: 1000
    t.datetime "created_at",                default: "now()", null: false
    t.datetime "updated_at",                default: "now()", null: false
  end

  create_table "jam_track_rights", id: :bigserial, force: :cascade do |t|
    t.string   "user_id",                        limit: 64,                   null: false
    t.string   "jam_track_id",                   limit: 64,                   null: false
    t.string   "url_48",                         limit: 2048
    t.string   "md5_48"
    t.integer  "length_48",                                   default: 0,     null: false
    t.integer  "download_count",                              default: 0,     null: false
    t.boolean  "downloaded_since_sign",                       default: false, null: false
    t.datetime "last_signed_at"
    t.datetime "last_downloaded_at"
    t.datetime "created_at",                                                  null: false
    t.datetime "updated_at",                                                  null: false
    t.datetime "signing_queued_at"
    t.integer  "error_count",                                 default: 0,     null: false
    t.string   "error_reason"
    t.string   "error_detail"
    t.boolean  "should_retry",                                default: false, null: false
    t.string   "url_44"
    t.string   "md5_44"
    t.integer  "length_44",                      limit: 8
    t.boolean  "redeemed",                                    default: false, null: false
    t.boolean  "is_test_purchase",                            default: false, null: false
    t.string   "recurly_adjustment_uuid",        limit: 500
    t.string   "recurly_adjustment_credit_uuid", limit: 500
    t.integer  "packaging_steps"
    t.integer  "current_packaging_step"
    t.datetime "last_step_at"
    t.string   "private_key_44"
    t.string   "private_key_48"
    t.boolean  "signed_48",                                   default: false, null: false
    t.boolean  "signed_44",                                   default: false, null: false
    t.datetime "signing_started_at_44"
    t.datetime "signing_started_at_48"
    t.datetime "first_downloaded_at"
    t.boolean  "signing_44",                                  default: false
    t.boolean  "signing_48",                                  default: false
    t.boolean  "redeemed_and_fingerprinted",                  default: false
    t.string   "last_mixdown_id",                limit: 64
    t.boolean  "queued",                                      default: false
    t.string   "last_stem_id",                   limit: 64
    t.string   "version",                                     default: "0",   null: false
    t.string   "posa_card_id",                   limit: 64
    t.boolean  "can_download",                                default: false, null: false
  end

  add_index "jam_track_rights", ["queued"], name: "jam_track_rights_queued", using: :btree
  add_index "jam_track_rights", ["signing_queued_at"], name: "jam_track_rights_signing_queued", using: :btree
  add_index "jam_track_rights", ["updated_at"], name: "jam_track_rights_updated", using: :btree
  add_index "jam_track_rights", ["user_id", "jam_track_id"], name: "jam_tracks_rights_uniqkey", using: :btree

  create_table "jam_track_sessions", force: :cascade do |t|
    t.string   "jam_track_id",     limit: 64,                   null: false
    t.string   "session_type",     limit: 10,                   null: false
    t.string   "music_session_id", limit: 64
    t.string   "user_id",          limit: 64
    t.datetime "created_at",                  default: "now()", null: false
    t.datetime "updated_at",                  default: "now()", null: false
  end

  create_table "jam_track_tap_ins", force: :cascade do |t|
    t.integer "offset_time",                         null: false
    t.string  "jam_track_id", limit: 64,             null: false
    t.decimal "bpm",                                 null: false
    t.integer "tap_in_count",            default: 0, null: false
  end

  create_table "jam_track_tracks", force: :cascade do |t|
    t.integer  "position"
    t.string   "track_type"
    t.string   "jam_track_id",       limit: 64,                   null: false
    t.string   "instrument_id",      limit: 64
    t.string   "part"
    t.string   "url_48"
    t.string   "md5_48"
    t.integer  "length_48",          limit: 8
    t.datetime "created_at",                    default: "now()", null: false
    t.datetime "updated_at",                    default: "now()", null: false
    t.string   "url_44"
    t.string   "md5_44"
    t.integer  "length_44",          limit: 8
    t.string   "preview_url"
    t.string   "preview_md5"
    t.integer  "preview_length",     limit: 8
    t.integer  "preview_start_time"
    t.string   "preview_mp3_url"
    t.string   "preview_mp3_md5"
    t.integer  "preview_mp3_length", limit: 8
    t.string   "original_filename"
    t.string   "preview_aac_url"
    t.string   "preview_aac_md5"
    t.integer  "preview_aac_length", limit: 8
    t.string   "url_mp3_48"
    t.string   "md5_mp3_48"
    t.integer  "length_mp3_48",      limit: 8
    t.string   "url_aac_48"
    t.string   "md5_aac_48"
    t.integer  "length_aac_48",      limit: 8
  end

  create_table "jam_tracks", force: :cascade do |t|
    t.string   "name",                                                                               null: false
    t.text     "description"
    t.string   "time_signature"
    t.string   "status"
    t.string   "recording_type"
    t.text     "original_artist"
    t.text     "songwriter"
    t.text     "publisher"
    t.string   "sales_region"
    t.decimal  "price"
    t.boolean  "reproduction_royalty"
    t.boolean  "public_performance_royalty"
    t.decimal  "reproduction_royalty_amount"
    t.decimal  "licensor_royalty_amount"
    t.string   "licensor_id",                 limit: 64
    t.datetime "created_at",                                                       default: "now()", null: false
    t.datetime "updated_at",                                                       default: "now()", null: false
    t.string   "plan_code",                   limit: 50
    t.string   "version",                                                          default: "0",     null: false
    t.string   "jmep_text"
    t.json     "jmep_json"
    t.string   "metalocation"
    t.boolean  "pro_ascap",                                                        default: false,   null: false
    t.boolean  "pro_bmi",                                                          default: false,   null: false
    t.boolean  "pro_sesac",                                                        default: false,   null: false
    t.integer  "duration"
    t.json     "onboarding_exceptions"
    t.string   "additional_info"
    t.string   "language",                                                         default: "eng",   null: false
    t.integer  "year"
    t.string   "vendor_id"
    t.tsvector "search_tsv"
    t.tsvector "artist_tsv"
    t.tsvector "name_tsv"
    t.date     "server_fixation_date",                                             default: "now()"
    t.boolean  "hfa_license_status",                                               default: false
    t.boolean  "hfa_license_desired",                                              default: true
    t.boolean  "alternative_license_status",                                       default: false
    t.integer  "hfa_license_number"
    t.string   "hfa_song_code"
    t.string   "album_title"
    t.string   "slug",                        limit: 2000
    t.decimal  "bpm",                                      precision: 8, scale: 3
    t.boolean  "allow_free",                                                       default: true
    t.decimal  "download_price"
  end

  add_index "jam_tracks", ["artist_tsv"], name: "jam_tracks_artist_tsv_index", using: :gin
  add_index "jam_tracks", ["language"], name: "jam_tracks_language_idx", using: :btree
  add_index "jam_tracks", ["metalocation"], name: "jam_tracks_metalocation_key", unique: true, using: :btree
  add_index "jam_tracks", ["name"], name: "jam_tracks_name_key", using: :btree
  add_index "jam_tracks", ["name_tsv"], name: "jam_tracks_name_tsv_index", using: :gin
  add_index "jam_tracks", ["original_artist"], name: "jam_tracks_original_artist_key", using: :btree
  add_index "jam_tracks", ["plan_code"], name: "plan_code_unique", unique: true, using: :btree
  add_index "jam_tracks", ["search_tsv"], name: "jam_tracks_search_tsv_index", using: :gin
  add_index "jam_tracks", ["slug"], name: "jam_tracks_slug_key", unique: true, using: :btree
  add_index "jam_tracks", ["status"], name: "jam_tracks_status_key", using: :btree

  create_table "jamblaster_pairing_requests", force: :cascade do |t|
    t.string   "user_id",              limit: 64,                     null: false
    t.string   "jamblaster_id",        limit: 64,                     null: false
    t.string   "jamblaster_client_id", limit: 64,                     null: false
    t.string   "sibling_key",          limit: 1000
    t.datetime "created_at",                        default: "now()", null: false
    t.datetime "updated_at",                        default: "now()", null: false
    t.string   "vtoken",               limit: 400,                    null: false
    t.boolean  "active",                            default: false,   null: false
  end

  create_table "jamblasters", force: :cascade do |t|
    t.string   "user_id",         limit: 64
    t.string   "serial_no",       limit: 1000
    t.string   "client_id",       limit: 64
    t.datetime "created_at",                   default: "now()", null: false
    t.datetime "updated_at",                   default: "now()", null: false
    t.string   "ipv6_link_local"
    t.string   "ipv4_link_local"
    t.string   "display_name"
  end

  add_index "jamblasters", ["client_id"], name: "jamblasters_client_id_key", unique: true, using: :btree
  add_index "jamblasters", ["serial_no"], name: "jamblasters_serial_no_key", unique: true, using: :btree

  create_table "jamblasters_users", force: :cascade do |t|
    t.string   "user_id",       limit: 64,                   null: false
    t.string   "jamblaster_id", limit: 64,                   null: false
    t.datetime "created_at",               default: "now()", null: false
    t.datetime "updated_at",               default: "now()", null: false
  end

  create_table "jamcompany", primary_key: "coid", force: :cascade do |t|
    t.string "company", limit: 50, null: false
  end

  add_index "jamcompany", ["company"], name: "jamcompany_company_ndx", unique: true, using: :btree

  create_table "jamisp", id: false, force: :cascade do |t|
    t.integer "beginip", limit: 8, null: false
    t.integer "endip",   limit: 8, null: false
    t.integer "coid",              null: false
  end

  add_index "jamisp", ["coid"], name: "jamisp_coid_ndx", using: :btree

  create_table "join_requests", force: :cascade do |t|
    t.string   "user_id",          limit: 64
    t.string   "music_session_id", limit: 64
    t.string   "text",             limit: 2000
    t.datetime "created_at",                    default: "now()", null: false
    t.datetime "updated_at",                    default: "now()", null: false
  end

  add_index "join_requests", ["user_id", "music_session_id"], name: "user_music_session_uniqkey", unique: true, using: :btree

  create_table "json_stores", force: :cascade do |t|
    t.string "user_id",         limit: 64
    t.string "foreign_key1_id", limit: 64
    t.json   "data_blob",                   default: {}, null: false
    t.string "type",            limit: 128
  end

  add_index "json_stores", ["foreign_key1_id"], name: "foreign_key1_idx", using: :btree
  add_index "json_stores", ["type"], name: "json_stores_type", using: :btree
  add_index "json_stores", ["user_id"], name: "user_idx", using: :btree

  create_table "languages", force: :cascade do |t|
    t.string "description", limit: 1024
  end

  create_table "latency_testers", force: :cascade do |t|
    t.string   "client_id",  limit: 64,                   null: false
    t.datetime "created_at",            default: "now()", null: false
    t.datetime "updated_at",            default: "now()", null: false
  end

  add_index "latency_testers", ["client_id"], name: "latency_testers_client_id_key", unique: true, using: :btree

  create_table "lesson_booking_slots", force: :cascade do |t|
    t.string   "lesson_booking_id", limit: 64
    t.string   "lesson_session_id", limit: 64
    t.string   "slot_type",         limit: 64,                   null: false
    t.date     "preferred_day"
    t.integer  "day_of_week"
    t.integer  "hour"
    t.integer  "minute"
    t.string   "timezone",                                       null: false
    t.string   "message"
    t.string   "accept_message"
    t.boolean  "update_all",                   default: false,   null: false
    t.string   "proposer_id",       limit: 64,                   null: false
    t.datetime "created_at",                   default: "now()", null: false
    t.datetime "updated_at",                   default: "now()", null: false
    t.boolean  "from_package",                 default: false
  end

  create_table "lesson_bookings", force: :cascade do |t|
    t.string   "user_id",                                limit: 64,                                           null: false
    t.boolean  "active",                                                                    default: false,   null: false
    t.string   "accepter_id",                            limit: 64
    t.string   "canceler_id",                            limit: 64
    t.string   "lesson_type",                            limit: 64,                                           null: false
    t.boolean  "recurring",                                                                                   null: false
    t.integer  "lesson_length",                                                                               null: false
    t.string   "payment_style",                          limit: 64,                                           null: false
    t.string   "description"
    t.decimal  "booked_price",                                      precision: 8, scale: 2,                   null: false
    t.string   "teacher_id",                             limit: 64,                                           null: false
    t.boolean  "card_presumed_ok",                                                          default: false,   null: false
    t.boolean  "sent_notices",                                                              default: false,   null: false
    t.string   "status"
    t.string   "cancel_message"
    t.boolean  "user_decremented",                                                          default: false,   null: false
    t.datetime "created_at",                                                                default: "now()", null: false
    t.datetime "updated_at",                                                                default: "now()", null: false
    t.string   "default_slot_id",                        limit: 64
    t.string   "counter_slot_id",                        limit: 64
    t.integer  "school_id"
    t.boolean  "same_school",                                                               default: false,   null: false
    t.boolean  "success"
    t.datetime "sent_notices_at"
    t.datetime "countered_at"
    t.string   "counterer_id",                           limit: 64
    t.boolean  "sent_counter_reminder",                                                     default: false,   null: false
    t.string   "test_drive_package_id",                  limit: 64
    t.string   "test_drive_package_choice_id",           limit: 64
    t.integer  "retailer_id"
    t.boolean  "same_school_free",                                                          default: false,   null: false
    t.string   "posa_card_id",                           limit: 64
    t.string   "payment"
    t.boolean  "same_retailer",                                                             default: false,   null: false
    t.boolean  "posa_card_purchased",                                                       default: false,   null: false
    t.integer  "remaining_roll_forward_amount_in_cents",                                    default: 0,       null: false
    t.boolean  "student_canceled",                                                          default: false,   null: false
    t.boolean  "teacher_canceled",                                                          default: false,   null: false
    t.datetime "student_canceled_at"
    t.datetime "teacher_canceled_at"
    t.string   "teacher_canceled_reason"
    t.string   "student_canceled_reason"
    t.datetime "canceled_by_admin"
  end

  create_table "lesson_package_purchases", force: :cascade do |t|
    t.string   "lesson_package_type_id",                 limit: 64,                                           null: false
    t.string   "user_id",                                limit: 64,                                           null: false
    t.string   "teacher_id",                             limit: 64
    t.decimal  "price",                                             precision: 8, scale: 2
    t.boolean  "recurring",                                                                 default: false,   null: false
    t.integer  "year"
    t.integer  "month"
    t.string   "charge_id",                              limit: 64
    t.string   "lesson_booking_id",                      limit: 64
    t.boolean  "sent_notices",                                                              default: false,   null: false
    t.datetime "sent_notices_at"
    t.boolean  "post_processed",                                                            default: false,   null: false
    t.datetime "post_processed_at"
    t.datetime "created_at",                                                                default: "now()", null: false
    t.datetime "updated_at",                                                                default: "now()", null: false
    t.string   "posa_card_id",                           limit: 64
    t.integer  "total_roll_forward_amount_in_cents"
    t.integer  "remaining_roll_forward_amount_in_cents"
    t.integer  "reduced_roll_forward_amount_in_cents",                                      default: 0,       null: false
    t.integer  "expected_session_times"
    t.integer  "actual_session_times"
  end

  create_table "lesson_package_types", force: :cascade do |t|
    t.string   "name",                                                               null: false
    t.string   "description",                                                        null: false
    t.string   "package_type",  limit: 64,                                           null: false
    t.decimal  "price",                    precision: 8, scale: 2
    t.datetime "created_at",                                       default: "now()", null: false
    t.datetime "updated_at",                                       default: "now()", null: false
    t.boolean  "is_test_drive",                                    default: true,    null: false
  end

  create_table "lesson_sessions", force: :cascade do |t|
    t.string   "lesson_type",                limit: 64,                                           null: false
    t.string   "teacher_id",                 limit: 64,                                           null: false
    t.string   "lesson_package_purchase_id", limit: 64
    t.string   "lesson_booking_id",          limit: 64
    t.integer  "duration",                                                                        null: false
    t.decimal  "booked_price",                          precision: 8, scale: 2,                   null: false
    t.boolean  "teacher_complete",                                              default: false,   null: false
    t.boolean  "student_complete",                                              default: false,   null: false
    t.boolean  "student_canceled",                                              default: false,   null: false
    t.boolean  "teacher_canceled",                                              default: false,   null: false
    t.datetime "student_canceled_at"
    t.datetime "teacher_canceled_at"
    t.string   "student_canceled_reason"
    t.string   "teacher_canceled_reason"
    t.string   "status"
    t.boolean  "analysed",                                                      default: false,   null: false
    t.json     "analysis"
    t.datetime "analysed_at"
    t.string   "cancel_message"
    t.string   "canceler_id",                limit: 64
    t.string   "charge_id",                  limit: 64
    t.boolean  "success",                                                       default: false,   null: false
    t.boolean  "sent_notices",                                                  default: false,   null: false
    t.datetime "sent_notices_at"
    t.boolean  "post_processed",                                                default: false,   null: false
    t.datetime "post_processed_at"
    t.datetime "created_at",                                                    default: "now()", null: false
    t.datetime "updated_at",                                                    default: "now()", null: false
    t.string   "counter_slot_id",            limit: 64
    t.string   "slot_id",                    limit: 64
    t.boolean  "teacher_unread_messages",                                       default: false,   null: false
    t.boolean  "student_unread_messages",                                       default: false,   null: false
    t.boolean  "student_short_canceled",                                        default: false,   null: false
    t.boolean  "teacher_short_canceled",                                        default: false,   null: false
    t.boolean  "sent_starting_notice",                                          default: false,   null: false
    t.string   "user_id",                    limit: 64,                                           null: false
    t.datetime "countered_at"
    t.string   "counterer_id",               limit: 64
    t.boolean  "admin_marked",                                                  default: false,   null: false
    t.boolean  "sent_counter_reminder",                                         default: false,   null: false
    t.datetime "sent_counter_reminder_at"
    t.datetime "canceled_by_admin"
    t.datetime "intervened_at"
    t.integer  "counter_reminders",                                             default: 0,       null: false
    t.boolean  "sent_early_starting_notice",                                    default: false,   null: false
  end

  add_index "lesson_sessions", ["charge_id"], name: "index_lesson_sessions_on_charge_id", using: :btree
  add_index "lesson_sessions", ["sent_counter_reminder"], name: "index_lesson_sessions_on_sent_counter_reminder", using: :btree
  add_index "lesson_sessions", ["sent_early_starting_notice"], name: "index_sent_early_starting_notice", using: :btree
  add_index "lesson_sessions", ["sent_starting_notice"], name: "index_sen_starting_notice", using: :btree
  add_index "lesson_sessions", ["status"], name: "index_lesson_sessions_on_status", using: :btree

  create_table "likes", force: :cascade do |t|
    t.string   "user_id",      limit: 64,                   null: false
    t.string   "likable_id",   limit: 64,                   null: false
    t.string   "likable_type", limit: 25,                   null: false
    t.datetime "created_at",              default: "now()", null: false
    t.datetime "updated_at",              default: "now()", null: false
  end

  add_index "likes", ["user_id", "likable_id"], name: "likes_user_uniqkey", unique: true, using: :btree

  create_table "live_streams", force: :cascade do |t|
    t.string   "slug",                         limit: 512,                    null: false
    t.text     "title"
    t.text     "description"
    t.text     "social_description"
    t.boolean  "listed",                                    default: false,   null: false
    t.datetime "starts_at"
    t.datetime "ends_at"
    t.string   "img_url",                      limit: 1024
    t.integer  "img_width"
    t.integer  "img_height"
    t.string   "youtube_code",                 limit: 1024
    t.string   "eventbriteid",                 limit: 1024
    t.string   "event_type",                   limit: 100
    t.string   "event_brite_registration_url", limit: 1024
    t.boolean  "allow_in",                                  default: false,   null: false
    t.boolean  "white_label_player",                        default: true,    null: false
    t.string   "user_id",                      limit: 64
    t.string   "band_id",                      limit: 64
    t.datetime "created_at",                                default: "now()", null: false
    t.datetime "updated_at",                                default: "now()", null: false
  end

  add_index "live_streams", ["slug"], name: "live_streams_slug_key", unique: true, using: :btree

  create_table "machine_extras", force: :cascade do |t|
    t.string   "machine_fingerprint_id", limit: 64,                    null: false
    t.string   "mac_address",            limit: 100
    t.string   "mac_name",               limit: 255
    t.boolean  "upstate"
    t.string   "ipaddr_0",               limit: 200
    t.string   "ipaddr_1",               limit: 200
    t.string   "ipaddr_2",               limit: 200
    t.string   "ipaddr_3",               limit: 200
    t.string   "ipaddr_4",               limit: 200
    t.string   "ipaddr_5",               limit: 200
    t.datetime "created_at",                         default: "now()", null: false
  end

  create_table "machine_fingerprints", force: :cascade do |t|
    t.string   "user_id",            limit: 64,                      null: false
    t.string   "fingerprint",        limit: 20000,                   null: false
    t.string   "when_taken",                                         null: false
    t.string   "print_type",                                         null: false
    t.string   "remote_ip",          limit: 1000,                    null: false
    t.integer  "jam_track_right_id", limit: 8
    t.datetime "created_at",                       default: "now()", null: false
  end

  add_index "machine_fingerprints", ["fingerprint", "user_id", "remote_ip", "created_at"], name: "machine_fingerprints_index1", using: :btree

  create_table "max_mind_releases", force: :cascade do |t|
    t.date     "released_at",                                      null: false
    t.boolean  "imported",                       default: false,   null: false
    t.date     "imported_at"
    t.string   "geo_ip_124_url",    limit: 2000
    t.string   "geo_ip_124_md5",    limit: 255
    t.integer  "geo_ip_124_size"
    t.string   "geo_ip_134_url",    limit: 2000
    t.string   "geo_ip_134_md5",    limit: 255
    t.integer  "geo_ip_134_size"
    t.string   "region_codes_url",  limit: 2000
    t.string   "region_codes_md5",  limit: 255
    t.integer  "region_codes_size"
    t.string   "iso3166_url",       limit: 2000
    t.string   "iso3166_md5",       limit: 255
    t.integer  "iso3166_size"
    t.string   "table_dumps_url",   limit: 2000
    t.string   "table_dumps_md5",   limit: 255
    t.integer  "table_dumps_size"
    t.datetime "created_at",                     default: "now()", null: false
    t.datetime "updated_at",                     default: "now()", null: false
  end

  add_index "max_mind_releases", ["released_at"], name: "max_mind_releases_released_at_key", unique: true, using: :btree

  create_table "mixes", id: :bigserial, force: :cascade do |t|
    t.string   "recording_id",       limit: 64,                     null: false
    t.string   "mix_server",         limit: 64
    t.datetime "started_at"
    t.datetime "completed_at"
    t.datetime "created_at",                      default: "now()", null: false
    t.datetime "updated_at",                      default: "now()", null: false
    t.string   "ogg_md5",            limit: 100
    t.integer  "ogg_length"
    t.string   "ogg_url",            limit: 1024
    t.boolean  "completed",                       default: false,   null: false
    t.integer  "error_count",                     default: 0,       null: false
    t.text     "error_reason"
    t.text     "error_detail"
    t.boolean  "should_retry",                    default: false,   null: false
    t.string   "mp3_md5",            limit: 100
    t.integer  "mp3_length"
    t.string   "mp3_url",            limit: 1024
    t.integer  "download_count",                  default: 0,       null: false
    t.datetime "last_downloaded_at"
  end

  add_index "mixes", ["completed_at"], name: "index_completed_at", using: :btree
  add_index "mixes", ["recording_id"], name: "mixes_recording_id_idx", using: :btree
  add_index "mixes", ["started_at"], name: "index_started_at", using: :btree

  create_table "mobile_recording_uploads", id: false, force: :cascade do |t|
    t.string   "id",                  limit: 64,   default: "uuid_generate_v4()", null: false
    t.string   "mobile_recording_id", limit: 64,                                  null: false
    t.string   "file_url",            limit: 1024
    t.string   "file_name",           limit: 255
    t.integer  "size"
    t.datetime "created_at",                       default: "now()",              null: false
    t.datetime "updated_at",                       default: "now()",              null: false
  end

  add_index "mobile_recording_uploads", ["mobile_recording_id"], name: "mobile_recording_id_idx", using: :btree

  create_table "music_notations", force: :cascade do |t|
    t.string   "user_id",          limit: 64,                       null: false
    t.string   "music_session_id", limit: 64
    t.string   "file_url",         limit: 512
    t.integer  "size"
    t.datetime "created_at",                   default: "now()",    null: false
    t.datetime "updated_at",                   default: "now()",    null: false
    t.string   "file_name",        limit: 255
    t.string   "attachment_type",              default: "notation", null: false
  end

  create_table "music_session_perf_data", force: :cascade do |t|
    t.string   "music_session_id", limit: 64
    t.string   "client_id",        limit: 64
    t.string   "uri",              limit: 1000
    t.datetime "created_at",                    default: "now()", null: false
    t.datetime "updated_at",                    default: "now()", null: false
  end

  create_table "music_sessions", force: :cascade do |t|
    t.string   "music_session_id",       limit: 64
    t.string   "description",            limit: 8000
    t.string   "user_id",                limit: 64,                                                              null: false
    t.string   "band_id",                limit: 64
    t.datetime "created_at",                          default: "now()",                                          null: false
    t.datetime "session_removed_at"
    t.integer  "play_count",                          default: 0,                                                null: false
    t.integer  "like_count",                          default: 0,                                                null: false
    t.boolean  "fan_access",                          default: true,                                             null: false
    t.datetime "scheduled_start"
    t.string   "scheduled_duration"
    t.boolean  "musician_access",                     default: true,                                             null: false
    t.boolean  "approval_required",                   default: false,                                            null: false
    t.boolean  "fan_chat",                            default: true,                                             null: false
    t.string   "genre_id",               limit: 64,                                                              null: false
    t.string   "legal_policy",           limit: 255,  default: "standard",                                       null: false
    t.string   "language",               limit: 255,  default: "eng",                                            null: false
    t.text     "name",                                                                                           null: false
    t.string   "recurring_session_id",   limit: 64
    t.string   "recurring_mode",         limit: 50,   default: "once",                                           null: false
    t.string   "timezone",               limit: 255
    t.datetime "started_at"
    t.boolean  "open_rsvps",                          default: false,                                            null: false
    t.boolean  "next_session_scheduled",              default: false
    t.tsvector "description_tsv"
    t.boolean  "is_unstructured_rsvp",                default: false
    t.boolean  "canceled",                            default: false
    t.string   "create_type",            limit: 64
    t.string   "session_controller_id",  limit: 64
    t.string   "lesson_session_id",      limit: 64
    t.boolean  "old",                                 default: false,                                            null: false
    t.boolean  "friends_can_join",                    default: false,                                            null: false
    t.integer  "music_session_id_int",                default: "nextval('music_sessions_id_int_seq'::regclass)", null: false
    t.integer  "school_id"
    t.boolean  "is_platform_instructor",              default: false,                                            null: false
  end

  add_index "music_sessions", ["band_id"], name: "band_id_for_feeds", using: :btree
  add_index "music_sessions", ["canceled"], name: "index_music_sessions_on_canceled", using: :btree
  add_index "music_sessions", ["create_type"], name: "index_music_sessions_on_create_type", using: :btree
  add_index "music_sessions", ["description_tsv"], name: "music_sessions_description_tsv_index", using: :gin
  add_index "music_sessions", ["lesson_session_id"], name: "index_music_sessions_on_lesson_session_id", using: :btree
  add_index "music_sessions", ["music_session_id"], name: "music_session_uniqkey", unique: true, using: :btree
  add_index "music_sessions", ["old"], name: "index_music_sessions_on_old", using: :btree
  add_index "music_sessions", ["scheduled_start"], name: "index_music_sessions_on_scheduled_start", using: :btree
  add_index "music_sessions", ["session_removed_at"], name: "index_music_sessions_on_session_removed_at", using: :btree
  add_index "music_sessions", ["started_at"], name: "index_music_sessions_on_started_at", using: :btree
  add_index "music_sessions", ["user_id"], name: "music_sessions_user_id_idx", using: :btree

  create_table "music_sessions_comments", force: :cascade do |t|
    t.string   "creator_id",       limit: 64,                     null: false
    t.string   "comment",          limit: 4000,                   null: false
    t.datetime "created_at",                    default: "now()", null: false
    t.datetime "updated_at",                    default: "now()", null: false
    t.inet     "ip_address"
    t.string   "music_session_id", limit: 64
  end

  create_table "music_sessions_likers", force: :cascade do |t|
    t.string   "liker_id",         limit: 64
    t.datetime "created_at",                  default: "now()", null: false
    t.datetime "updated_at",                  default: "now()", null: false
    t.inet     "ip_address"
    t.string   "music_session_id", limit: 64
  end

  create_table "music_sessions_user_history", id: false, force: :cascade do |t|
    t.string   "id",                         limit: 64,  default: "uuid_generate_v4()", null: false
    t.string   "user_id",                    limit: 64,                                 null: false
    t.string   "client_id",                  limit: 64,                                 null: false
    t.datetime "created_at",                             default: "now()",              null: false
    t.datetime "session_removed_at"
    t.integer  "max_concurrent_connections"
    t.integer  "rating"
    t.string   "instruments",                limit: 255
    t.text     "rating_comment"
    t.string   "music_session_id",           limit: 64
    t.string   "backend_details"
  end

  add_index "music_sessions_user_history", ["client_id"], name: "msuh_client_id", using: :btree
  add_index "music_sessions_user_history", ["created_at"], name: "msuh_created_at", using: :btree
  add_index "music_sessions_user_history", ["id"], name: "msuh_id_idx", using: :btree
  add_index "music_sessions_user_history", ["music_session_id"], name: "msuh_music_session_idx", using: :btree
  add_index "music_sessions_user_history", ["music_session_id"], name: "msuh_record_id_for_feeds", using: :btree
  add_index "music_sessions_user_history", ["user_id"], name: "msuh_user_id", using: :btree

  create_table "musicians_instruments", force: :cascade do |t|
    t.string   "player_id",         limit: 64,                   null: false
    t.string   "instrument_id",     limit: 64,                   null: false
    t.integer  "proficiency_level", limit: 2,                    null: false
    t.integer  "priority",          limit: 2,  default: 1,       null: false
    t.datetime "created_at",                   default: "now()", null: false
    t.datetime "updated_at",                   default: "now()", null: false
    t.string   "player_type",       limit: 32, default: "user"
  end

  add_index "musicians_instruments", ["player_id", "instrument_id"], name: "musician_instrument_uniqkey", unique: true, using: :btree

  create_table "news", force: :cascade do |t|
    t.string   "title",                        null: false
    t.string   "body",                         null: false
    t.integer  "position",                     null: false
    t.datetime "created_at", default: "now()", null: false
    t.datetime "updated_at", default: "now()", null: false
  end

  add_index "news", ["position"], name: "news_position_key", unique: true, using: :btree

  create_table "notifications", force: :cascade do |t|
    t.string   "description",                  limit: 100,                   null: false
    t.string   "source_user_id",               limit: 64
    t.string   "target_user_id",               limit: 64
    t.string   "band_id",                      limit: 64
    t.string   "session_id",                   limit: 64
    t.string   "recording_id",                 limit: 64
    t.string   "invitation_id",                limit: 64
    t.string   "join_request_id",              limit: 64
    t.datetime "created_at",                               default: "now()", null: false
    t.datetime "updated_at",                               default: "now()", null: false
    t.string   "friend_request_id",            limit: 64
    t.string   "band_invitation_id",           limit: 64
    t.text     "message"
    t.integer  "jam_track_right_id",           limit: 8
    t.string   "jam_track_mixdown_package_id", limit: 64
    t.string   "lesson_session_id",            limit: 64
    t.string   "purpose",                      limit: 200
    t.boolean  "student_directed"
  end

  create_table "online_presences", force: :cascade do |t|
    t.string   "player_id",    limit: 64,                    null: false
    t.string   "service_type", limit: 100,                   null: false
    t.string   "username",     limit: 100,                   null: false
    t.datetime "created_at",               default: "now()", null: false
    t.datetime "updated_at",               default: "now()", null: false
    t.string   "player_type",  limit: 32,  default: "user"
  end

  create_table "performance_samples", force: :cascade do |t|
    t.string   "player_id",            limit: 64,                     null: false
    t.string   "url",                  limit: 4000
    t.string   "service_type",         limit: 100,                    null: false
    t.string   "claimed_recording_id", limit: 64
    t.string   "service_id",           limit: 100
    t.datetime "created_at",                        default: "now()", null: false
    t.datetime "updated_at",                        default: "now()", null: false
    t.string   "description",          limit: 256
    t.string   "player_type",          limit: 32,   default: "user"
  end

  create_table "playable_plays", force: :cascade do |t|
    t.string   "playable_id",          limit: 64
    t.string   "playable_type",        limit: 128
    t.string   "player_id",            limit: 64
    t.string   "claimed_recording_id", limit: 64
    t.inet     "ip_address"
    t.datetime "created_at",                       default: "now()", null: false
    t.datetime "updated_at",                       default: "now()", null: false
  end

  create_table "posa_card_purchases", force: :cascade do |t|
    t.string   "user_id",                        limit: 64,                    null: false
    t.string   "posa_card_type_id",              limit: 64
    t.string   "posa_card_id",                   limit: 64
    t.string   "recurly_adjustment_uuid",        limit: 500
    t.string   "recurly_adjustment_credit_uuid", limit: 500
    t.datetime "created_at",                                 default: "now()", null: false
    t.datetime "updated_at",                                 default: "now()", null: false
  end

  create_table "posa_card_types", force: :cascade do |t|
    t.string   "card_type",  limit: 64,                   null: false
    t.datetime "created_at",            default: "now()", null: false
    t.datetime "updated_at",            default: "now()", null: false
  end

  create_table "posa_cards", force: :cascade do |t|
    t.string   "code",                   limit: 64,                    null: false
    t.string   "user_id",                limit: 64
    t.string   "card_type",              limit: 64,                    null: false
    t.string   "origin",                 limit: 200
    t.datetime "activated_at"
    t.datetime "claimed_at"
    t.integer  "retailer_id"
    t.datetime "created_at",                         default: "now()", null: false
    t.datetime "updated_at",                         default: "now()", null: false
    t.string   "lesson_package_type_id", limit: 64
    t.integer  "credits",                            default: 1,       null: false
    t.boolean  "is_lesson",                          default: false,   null: false
    t.boolean  "preactivate",                        default: false,   null: false
    t.boolean  "requires_purchase",                  default: false,   null: false
    t.boolean  "purchased",                          default: true,    null: false
    t.boolean  "is_test",                            default: false
  end

  add_index "posa_cards", ["code"], name: "posa_cards_code_key", unique: true, using: :btree
  add_index "posa_cards", ["lesson_package_type_id"], name: "index_posa_cards_lesson_package_type_id", using: :btree
  add_index "posa_cards", ["user_id"], name: "posa_card_user_id_idx", using: :btree

  create_table "promotionals", force: :cascade do |t|
    t.string   "type",        limit: 128,  default: "JamRuby::PromoBuzz", null: false
    t.string   "aasm_state",  limit: 64,   default: "hidden"
    t.integer  "position",                 default: 0,                    null: false
    t.datetime "created_at",               default: "now()",              null: false
    t.datetime "updated_at",               default: "now()",              null: false
    t.string   "latest_id",   limit: 64
    t.string   "latest_type", limit: 128
    t.string   "image",       limit: 1024
    t.string   "text_short",  limit: 512
    t.string   "text_long",   limit: 4096
  end

  add_index "promotionals", ["latest_id", "latest_type"], name: "promo_latest_idx", using: :btree

  create_table "quick_mixes", id: :bigserial, force: :cascade do |t|
    t.integer  "next_part_to_upload",              default: 0,       null: false
    t.boolean  "fully_uploaded",                   default: false,   null: false
    t.string   "upload_id",           limit: 1024
    t.integer  "file_offset",         limit: 8,    default: 0
    t.boolean  "is_part_uploading",                default: false,   null: false
    t.integer  "upload_failures",                  default: 0
    t.integer  "part_failures",                    default: 0
    t.string   "ogg_md5",             limit: 100
    t.integer  "ogg_length"
    t.string   "ogg_url",             limit: 1000
    t.string   "mp3_md5",             limit: 100
    t.integer  "mp3_length"
    t.string   "mp3_url",             limit: 1000
    t.integer  "error_count",                      default: 0,       null: false
    t.text     "error_reason"
    t.text     "error_detail"
    t.datetime "created_at",                       default: "now()", null: false
    t.datetime "updated_at",                       default: "now()", null: false
    t.datetime "started_at"
    t.datetime "completed_at"
    t.boolean  "completed",                        default: false,   null: false
    t.boolean  "should_retry",                     default: false,   null: false
    t.boolean  "cleaned",                          default: false,   null: false
    t.string   "user_id",             limit: 64
    t.string   "recording_id",        limit: 64
  end

  add_index "quick_mixes", ["cleaned"], name: "index_quick_mixes_on_cleaned", using: :btree
  add_index "quick_mixes", ["completed"], name: "index_quick_mixes_on_completed", using: :btree
  add_index "quick_mixes", ["recording_id"], name: "index_quick_mixes_on_recording_id", using: :btree
  add_index "quick_mixes", ["user_id"], name: "quick_mixes_user_id_idx", using: :btree

  create_table "recorded_backing_tracks", id: :bigserial, force: :cascade do |t|
    t.string   "user_id",             limit: 64
    t.string   "backing_track_id",    limit: 64
    t.string   "recording_id",        limit: 64,                     null: false
    t.string   "client_track_id",     limit: 64,                     null: false
    t.boolean  "is_part_uploading",                default: false,   null: false
    t.integer  "next_part_to_upload",              default: 0,       null: false
    t.string   "upload_id",           limit: 1024
    t.integer  "part_failures",                    default: 0,       null: false
    t.boolean  "discard"
    t.integer  "download_count",                   default: 0,       null: false
    t.string   "md5",                 limit: 100
    t.integer  "length",              limit: 8
    t.string   "client_id",           limit: 64,                     null: false
    t.integer  "file_offset",         limit: 8
    t.string   "url",                 limit: 1024,                   null: false
    t.boolean  "fully_uploaded",                   default: false,   null: false
    t.integer  "upload_failures",                  default: 0,       null: false
    t.datetime "created_at",                       default: "now()", null: false
    t.datetime "updated_at",                       default: "now()", null: false
    t.string   "filename",                                           null: false
    t.datetime "last_downloaded_at"
  end

  add_index "recorded_backing_tracks", ["recording_id"], name: "recorded_backing_tracks_recording_id_idx", using: :btree
  add_index "recorded_backing_tracks", ["user_id"], name: "recorded_backing_tracks_user_id_idx", using: :btree

  create_table "recorded_jam_track_tracks", id: :bigserial, force: :cascade do |t|
    t.string   "user_id",            limit: 64,                   null: false
    t.string   "jam_track_track_id", limit: 64,                   null: false
    t.string   "recording_id",       limit: 64,                   null: false
    t.boolean  "discard"
    t.json     "timeline"
    t.datetime "created_at",                    default: "now()", null: false
    t.datetime "updated_at",                    default: "now()", null: false
  end

  create_table "recorded_tracks", id: :bigserial, force: :cascade do |t|
    t.string   "user_id",             limit: 64,                     null: false
    t.string   "instrument_id",       limit: 64,                     null: false
    t.string   "sound",               limit: 64,                     null: false
    t.integer  "next_part_to_upload",              default: 0,       null: false
    t.boolean  "fully_uploaded",                   default: false,   null: false
    t.datetime "created_at",                       default: "now()", null: false
    t.datetime "updated_at",                       default: "now()", null: false
    t.string   "upload_id",           limit: 1024
    t.string   "recording_id",        limit: 64,                     null: false
    t.string   "md5",                 limit: 100
    t.integer  "length",              limit: 8
    t.string   "client_id",           limit: 64,                     null: false
    t.string   "track_id",            limit: 64,                     null: false
    t.string   "url",                 limit: 1024
    t.integer  "file_offset",         limit: 8,    default: 0
    t.string   "client_track_id",     limit: 64,                     null: false
    t.boolean  "is_part_uploading",                default: false,   null: false
    t.integer  "upload_failures",                  default: 0,       null: false
    t.integer  "part_failures",                    default: 0,       null: false
    t.boolean  "discard"
    t.integer  "download_count",                   default: 0,       null: false
    t.datetime "last_downloaded_at"
  end

  add_index "recorded_tracks", ["recording_id"], name: "recorded_tracks_recording_id_idx", using: :btree
  add_index "recorded_tracks", ["user_id"], name: "recorded_tracks_user_id_idx", using: :btree

  create_table "recorded_videos", id: :bigserial, force: :cascade do |t|
    t.string   "user_id",                limit: 64
    t.boolean  "fully_uploaded",                      default: false,   null: false
    t.string   "recording_id",           limit: 64,                     null: false
    t.integer  "length",                 limit: 8
    t.string   "client_video_source_id", limit: 64,                     null: false
    t.string   "url",                    limit: 1024
    t.integer  "file_offset",            limit: 8
    t.integer  "upload_failures",                     default: 0,       null: false
    t.boolean  "discard"
    t.datetime "created_at",                          default: "now()", null: false
    t.datetime "updated_at",                          default: "now()", null: false
  end

  add_index "recorded_videos", ["user_id"], name: "recorded_videos_user_id_idx", using: :btree

  create_table "recordings", force: :cascade do |t|
    t.datetime "created_at",                          default: "now()", null: false
    t.datetime "updated_at",                          default: "now()", null: false
    t.string   "owner_id",               limit: 64,                     null: false
    t.string   "music_session_id",       limit: 64
    t.string   "band_id",                limit: 64
    t.integer  "duration"
    t.boolean  "is_done",                             default: false
    t.boolean  "all_discarded",                       default: false,   null: false
    t.string   "name",                   limit: 1024
    t.integer  "play_count",                          default: 0,       null: false
    t.integer  "like_count",                          default: 0,       null: false
    t.boolean  "has_stream_mix",                      default: false,   null: false
    t.boolean  "has_final_mix",                       default: false,   null: false
    t.integer  "first_quick_mix_id",     limit: 8
    t.boolean  "deleted",                             default: false,   null: false
    t.string   "jam_track_id",           limit: 64
    t.string   "jam_track_initiator_id", limit: 64
    t.json     "timeline"
    t.boolean  "video",                               default: false,   null: false
    t.string   "external_video_id"
    t.boolean  "immediate",                           default: false
    t.integer  "school_id"
    t.boolean  "is_platform_instructor",              default: false,   null: false
  end

  add_index "recordings", ["all_discarded"], name: "index_recordings_on_all_discarded", using: :btree
  add_index "recordings", ["band_id"], name: "band_id_2_for_feeds", using: :btree
  add_index "recordings", ["deleted"], name: "index_recordings_on_deleted", using: :btree
  add_index "recordings", ["first_quick_mix_id"], name: "index_recordings_on_first_quick_mix_id", using: :btree
  add_index "recordings", ["has_final_mix"], name: "index_recordings_on_has_final_mix", using: :btree

  create_table "recordings_comments", force: :cascade do |t|
    t.string   "recording_id", limit: 64,                     null: false
    t.string   "creator_id",   limit: 64,                     null: false
    t.string   "comment",      limit: 4000,                   null: false
    t.datetime "created_at",                default: "now()", null: false
    t.datetime "updated_at",                default: "now()", null: false
    t.inet     "ip_address"
  end

  create_table "recordings_downloads", force: :cascade do |t|
    t.string   "recording_id",  limit: 64,                   null: false
    t.string   "downloader_id", limit: 64,                   null: false
    t.datetime "created_at",               default: "now()", null: false
    t.datetime "updated_at",               default: "now()", null: false
  end

  create_table "recordings_likers", force: :cascade do |t|
    t.string   "recording_id",         limit: 64,                   null: false
    t.string   "liker_id",             limit: 64
    t.datetime "created_at",                      default: "now()", null: false
    t.datetime "updated_at",                      default: "now()", null: false
    t.inet     "ip_address"
    t.string   "claimed_recording_id", limit: 64,                   null: false
    t.boolean  "favorite",                        default: true,    null: false
  end

  add_index "recordings_likers", ["recording_id", "liker_id"], name: "recording_liker_uniqkey", unique: true, using: :btree

  create_table "recurly_transaction_web_hooks", force: :cascade do |t|
    t.string   "recurly_transaction_id",                              null: false
    t.string   "transaction_type",                                    null: false
    t.string   "subscription_id"
    t.string   "action",                                              null: false
    t.string   "status",                                              null: false
    t.integer  "amount_in_cents"
    t.string   "user_id",                limit: 64,                   null: false
    t.string   "invoice_id"
    t.string   "invoice_number_prefix"
    t.integer  "invoice_number"
    t.string   "message"
    t.string   "reference"
    t.datetime "transaction_at",                                      null: false
    t.datetime "created_at",                        default: "now()", null: false
    t.string   "admin_description"
    t.string   "jam_track_id",           limit: 64
  end

  add_index "recurly_transaction_web_hooks", ["invoice_id"], name: "recurly_transaction_web_hooks_invoice_id_ndx", using: :btree
  add_index "recurly_transaction_web_hooks", ["subscription_id"], name: "recurly_transaction_web_hooks_subscription_id_ndx", using: :btree

  create_table "recurring_sessions", force: :cascade do |t|
    t.string   "description",        limit: 8000
    t.datetime "scheduled_start"
    t.string   "scheduled_duration"
    t.boolean  "musician_access",                                      null: false
    t.boolean  "approval_required",                                    null: false
    t.boolean  "fan_chat",                                             null: false
    t.string   "genre_id",           limit: 64
    t.string   "legal_policy",       limit: 255,  default: "standard", null: false
    t.string   "language",           limit: 255,  default: "en",       null: false
    t.text     "name"
    t.string   "user_id",            limit: 64,                        null: false
    t.string   "band_id",            limit: 64
    t.datetime "created_at",                      default: "now()",    null: false
    t.datetime "updated_at",                      default: "now()",    null: false
  end

  create_table "regions", id: false, force: :cascade do |t|
    t.string "region",      limit: 2,  null: false
    t.string "regionname",  limit: 64
    t.string "countrycode", limit: 2,  null: false
  end

  add_index "regions", ["countrycode", "region"], name: "regions_countrycode_region_ndx", unique: true, using: :btree
  add_index "regions", ["countrycode"], name: "regions_countrycode_ndx", using: :btree

  create_table "retailer_invitations", force: :cascade do |t|
    t.string   "user_id",         limit: 64
    t.integer  "retailer_id",                                   null: false
    t.string   "invitation_code", limit: 256,                   null: false
    t.string   "note"
    t.string   "email",                                         null: false
    t.string   "first_name"
    t.string   "last_name"
    t.boolean  "accepted",                    default: false,   null: false
    t.datetime "created_at",                  default: "now()", null: false
    t.datetime "updated_at",                  default: "now()", null: false
  end

  add_index "retailer_invitations", ["invitation_code"], name: "retailer_invitations_invitation_code_key", unique: true, using: :btree

  create_table "retailers", force: :cascade do |t|
    t.string   "user_id",               limit: 64,                                                          null: false
    t.string   "name"
    t.boolean  "enabled",                                                    default: true
    t.string   "city"
    t.string   "state"
    t.string   "slug"
    t.string   "encrypted_password",                                         default: "uuid_generate_v4()", null: false
    t.string   "photo_url",             limit: 2048
    t.string   "original_fpfile",       limit: 8000
    t.string   "cropped_fpfile",        limit: 8000
    t.string   "cropped_s3_path",       limit: 8000
    t.string   "crop_selection",        limit: 256
    t.string   "large_photo_url",       limit: 512
    t.string   "cropped_large_s3_path", limit: 512
    t.string   "cropped_large_fpfile",  limit: 8000
    t.datetime "created_at",                                                 default: "now()",              null: false
    t.datetime "updated_at",                                                 default: "now()",              null: false
    t.decimal  "jamkazam_rate",                      precision: 8, scale: 2, default: 0.25
    t.integer  "affiliate_partner_id"
    t.string   "payment"
    t.string   "special"
  end

  add_index "retailers", ["special"], name: "retailers_special_key", unique: true, using: :btree

  create_table "review_summaries", force: :cascade do |t|
    t.string   "target_id",    limit: 64,                   null: false
    t.string   "target_type",  limit: 32,                   null: false
    t.float    "avg_rating",                                null: false
    t.float    "wilson_score",                              null: false
    t.integer  "review_count",                              null: false
    t.datetime "created_at",              default: "now()", null: false
    t.datetime "updated_at",              default: "now()", null: false
  end

  create_table "reviews", force: :cascade do |t|
    t.string   "user_id",            limit: 64,                   null: false
    t.string   "target_id",          limit: 64,                   null: false
    t.string   "target_type",        limit: 32,                   null: false
    t.string   "description"
    t.integer  "rating",                                          null: false
    t.string   "deleted_by_user_id", limit: 64
    t.datetime "deleted_at"
    t.datetime "created_at",                    default: "now()", null: false
    t.datetime "updated_at",                    default: "now()", null: false
  end

  create_table "rsvp_requests", force: :cascade do |t|
    t.string   "user_id",          limit: 64,                   null: false
    t.boolean  "canceled",                    default: false
    t.datetime "created_at",                  default: "now()", null: false
    t.datetime "updated_at",                  default: "now()", null: false
    t.boolean  "cancel_all",                  default: false
    t.string   "music_session_id", limit: 64
    t.boolean  "chosen",                      default: false,   null: false
  end

  add_index "rsvp_requests", ["canceled"], name: "index_rsvp_requests_canceled", using: :btree
  add_index "rsvp_requests", ["music_session_id"], name: "rsvp_request_music_session_id", using: :btree
  add_index "rsvp_requests", ["user_id"], name: "index_rsvp_requests_user_id", using: :btree

  create_table "rsvp_requests_rsvp_slots", force: :cascade do |t|
    t.string   "rsvp_request_id", limit: 64,                   null: false
    t.string   "rsvp_slot_id",    limit: 64,                   null: false
    t.boolean  "chosen"
    t.datetime "created_at",                 default: "now()", null: false
    t.datetime "updated_at",                 default: "now()", null: false
  end

  add_index "rsvp_requests_rsvp_slots", ["chosen"], name: "index_rsvp_requests_rsvp_slots_on_chosen", using: :btree
  add_index "rsvp_requests_rsvp_slots", ["rsvp_request_id"], name: "index_rsvp_requests_rsvp_slots_on_rsvp_request_id", using: :btree
  add_index "rsvp_requests_rsvp_slots", ["rsvp_slot_id"], name: "index_rsvp_requests_rsvp_slots_on_rsvp_slot_id", using: :btree

  create_table "rsvp_slots", force: :cascade do |t|
    t.string   "instrument_id",        limit: 64
    t.integer  "proficiency_level",    limit: 2
    t.string   "music_session_id",     limit: 64,                   null: false
    t.datetime "created_at",                      default: "now()", null: false
    t.datetime "updated_at",                      default: "now()", null: false
    t.boolean  "is_unstructured_rsvp",            default: false
  end

  add_index "rsvp_slots", ["music_session_id"], name: "index_rsvp_slots_on_music_session_id", using: :btree

  create_table "sale_line_items", force: :cascade do |t|
    t.string   "product_type",                                                  null: false
    t.string   "product_id",                      limit: 64
    t.decimal  "unit_price",                                                    null: false
    t.integer  "quantity",                                                      null: false
    t.integer  "free",                                                          null: false
    t.decimal  "sales_tax"
    t.decimal  "shipping_handling",                                             null: false
    t.string   "recurly_plan_code",                                             null: false
    t.string   "recurly_subscription_uuid"
    t.string   "sale_id",                         limit: 64,                    null: false
    t.datetime "created_at",                                  default: "now()", null: false
    t.datetime "updated_at",                                  default: "now()", null: false
    t.string   "recurly_adjustment_uuid",         limit: 500
    t.string   "recurly_adjustment_credit_uuid",  limit: 500
    t.integer  "recurly_tax_in_cents"
    t.integer  "recurly_total_in_cents"
    t.string   "recurly_currency"
    t.integer  "recurly_discount_in_cents"
    t.integer  "affiliate_referral_id"
    t.integer  "affiliate_referral_fee_in_cents"
    t.boolean  "affiliate_refunded",                          default: false,   null: false
    t.datetime "affiliate_refunded_at"
    t.string   "gift_card_purchase_id",           limit: 64
    t.string   "lesson_package_purchase_id",      limit: 64
    t.string   "posa_card_purchase_id",           limit: 64
    t.integer  "retailer_id"
    t.string   "variant"
  end

  add_index "sale_line_items", ["recurly_subscription_uuid"], name: "sale_line_items_recurly_subscription_uuid_ndx", unique: true, using: :btree

  create_table "sales", force: :cascade do |t|
    t.string   "user_id",                   limit: 64
    t.decimal  "order_total",                           default: 0.0,        null: false
    t.json     "shipping_info"
    t.datetime "created_at",                            default: "now()",    null: false
    t.datetime "updated_at",                            default: "now()",    null: false
    t.string   "recurly_invoice_id",        limit: 500
    t.integer  "recurly_invoice_number"
    t.integer  "recurly_subtotal_in_cents"
    t.integer  "recurly_tax_in_cents"
    t.integer  "recurly_total_in_cents"
    t.string   "recurly_currency"
    t.string   "sale_type",                             default: "jamtrack", null: false
    t.string   "source",                                default: "recurly",  null: false
    t.string   "stripe_charge_id",          limit: 200
    t.integer  "retailer_id"
  end

  add_index "sales", ["recurly_invoice_id"], name: "sales_recurly_invoice_id_key", unique: true, using: :btree

  create_table "school_invitations", force: :cascade do |t|
    t.string   "user_id",         limit: 64
    t.integer  "school_id",                                     null: false
    t.string   "invitation_code", limit: 256,                   null: false
    t.string   "note"
    t.boolean  "as_teacher",                                    null: false
    t.string   "email",                                         null: false
    t.string   "first_name"
    t.string   "last_name"
    t.boolean  "accepted",                    default: false,   null: false
    t.datetime "created_at",                  default: "now()", null: false
    t.datetime "updated_at",                  default: "now()", null: false
  end

  add_index "school_invitations", ["invitation_code"], name: "school_invitations_invitation_code_key", unique: true, using: :btree

  create_table "schools", force: :cascade do |t|
    t.string   "user_id",                  limit: 64,                                               null: false
    t.string   "name"
    t.boolean  "enabled",                                                       default: true
    t.string   "scheduling_communication",                                      default: "teacher", null: false
    t.string   "correspondence_email"
    t.string   "photo_url",                limit: 2048
    t.string   "original_fpfile",          limit: 8000
    t.string   "cropped_fpfile",           limit: 8000
    t.string   "cropped_s3_path",          limit: 8000
    t.string   "crop_selection",           limit: 256
    t.string   "large_photo_url",          limit: 512
    t.string   "cropped_large_s3_path",    limit: 512
    t.string   "cropped_large_fpfile",     limit: 8000
    t.datetime "created_at",                                                    default: "now()",   null: false
    t.datetime "updated_at",                                                    default: "now()",   null: false
    t.decimal  "jamkazam_rate",                         precision: 8, scale: 2, default: 0.2
    t.integer  "affiliate_partner_id"
    t.boolean  "education",                                                     default: false,     null: false
    t.string   "special"
    t.decimal  "base_rate",                             precision: 8, scale: 2, default: 0.1
    t.string   "school_tag",               limit: 100
  end

  add_index "schools", ["name"], name: "schools_name_uniqkey", unique: true, using: :btree
  add_index "schools", ["school_tag"], name: "schools_school_tag_key", unique: true, using: :btree
  add_index "schools", ["special"], name: "schools_special_key", unique: true, using: :btree

  create_table "score_histories", id: false, force: :cascade do |t|
    t.string   "from_client_id",         limit: 64
    t.integer  "from_addr",              limit: 8
    t.string   "from_isp",               limit: 50
    t.string   "from_country",           limit: 64
    t.string   "from_region",            limit: 64
    t.string   "from_city",              limit: 255
    t.string   "from_postal",            limit: 25
    t.float    "from_latitude"
    t.float    "from_longitude"
    t.string   "to_client_id",           limit: 64
    t.integer  "to_addr",                limit: 8
    t.string   "to_isp",                 limit: 50
    t.string   "to_country",             limit: 64
    t.string   "to_region",              limit: 64
    t.string   "to_city",                limit: 255
    t.string   "to_postal",              limit: 25
    t.float    "to_latitude"
    t.float    "to_longitude"
    t.integer  "score",                              null: false
    t.datetime "score_dt",                           null: false
    t.text     "scoring_data"
    t.string   "from_user_id",           limit: 64
    t.string   "to_user_id",             limit: 64
    t.string   "from_latency_tester_id", limit: 64
    t.string   "to_latency_tester_id",   limit: 64
    t.integer  "from_locidispid",        limit: 8,   null: false
    t.integer  "to_locidispid",          limit: 8,   null: false
  end

  create_table "scores", id: false, force: :cascade do |t|
    t.integer  "alocidispid",    limit: 8,                      null: false
    t.string   "anodeid",        limit: 64,                     null: false
    t.integer  "aaddr",          limit: 8,                      null: false
    t.integer  "blocidispid",    limit: 8,                      null: false
    t.string   "bnodeid",        limit: 64,                     null: false
    t.integer  "baddr",          limit: 8,                      null: false
    t.integer  "score",                                         null: false
    t.integer  "scorer",                                        null: false
    t.datetime "score_dt",                    default: "now()", null: false
    t.string   "scoring_data",   limit: 4000
    t.datetime "created_at",                  default: "now()", null: false
    t.string   "auserid",        limit: 64
    t.string   "buserid",        limit: 64
    t.string   "alatencytestid", limit: 64
    t.string   "blatencytestid", limit: 64
  end

  add_index "scores", ["alocidispid", "blocidispid", "score_dt"], name: "scores_alocidispid_blocidispid_score_dt_ndx", using: :btree
  add_index "scores", ["blocidispid", "alocidispid", "score_dt"], name: "scores_blocidispid_alocidispid_score_dt_ndx", using: :btree

  create_table "session_info_comments", force: :cascade do |t|
    t.string   "music_session_id", limit: 64,                   null: false
    t.string   "creator_id",       limit: 64,                   null: false
    t.text     "comment",                                       null: false
    t.datetime "created_at",                  default: "now()", null: false
    t.datetime "updated_at",                  default: "now()", null: false
  end

  create_table "share_tokens", force: :cascade do |t|
    t.string   "token",          limit: 15,                   null: false
    t.string   "shareable_id",   limit: 64,                   null: false
    t.string   "shareable_type", limit: 50,                   null: false
    t.datetime "created_at",                default: "now()", null: false
    t.datetime "updated_at",                default: "now()", null: false
  end

  add_index "share_tokens", ["shareable_id"], name: "index_share_tokens_on_shareable_id", using: :btree
  add_index "share_tokens", ["token"], name: "token_uniqkey", unique: true, using: :btree

  create_table "shopping_carts", force: :cascade do |t|
    t.integer  "quantity",                       default: 1,       null: false
    t.string   "user_id",           limit: 64
    t.string   "cart_id",           limit: 64,                     null: false
    t.string   "cart_class_name",   limit: 64
    t.string   "cart_type",         limit: 64
    t.datetime "created_at",                     default: "now()", null: false
    t.datetime "updated_at",                     default: "now()", null: false
    t.string   "anonymous_user_id", limit: 1000
    t.integer  "marked_for_redeem",              default: 0,       null: false
    t.string   "variant"
  end

  create_table "signup_hints", force: :cascade do |t|
    t.string   "anonymous_user_id", limit: 64
    t.string   "redirect_location"
    t.boolean  "want_jamblaster",              default: false,   null: false
    t.string   "user_id",           limit: 64
    t.datetime "expires_at"
    t.datetime "created_at",                   default: "now()", null: false
    t.datetime "updated_at",                   default: "now()", null: false
  end

  add_index "signup_hints", ["anonymous_user_id"], name: "signup_hints_anonymous_user_id_key", unique: true, using: :btree

  create_table "subjects", force: :cascade do |t|
    t.string "description", limit: 1024
  end

  create_table "teacher_distributions", force: :cascade do |t|
    t.string   "teacher_id",                           limit: 64,                   null: false
    t.string   "teacher_payment_id",                   limit: 64
    t.string   "lesson_session_id",                    limit: 64
    t.string   "lesson_package_purchase_id",           limit: 64
    t.integer  "amount_in_cents",                                                   null: false
    t.boolean  "ready",                                           default: false,   null: false
    t.boolean  "distributed",                                     default: false,   null: false
    t.datetime "created_at",                                      default: "now()", null: false
    t.datetime "updated_at",                                      default: "now()", null: false
    t.integer  "school_id"
    t.integer  "retailer_id"
    t.boolean  "education",                                       default: false,   null: false
    t.integer  "teacher_fee_in_cents"
    t.integer  "reduced_roll_forward_amount_in_cents",            default: 0,       null: false
  end

  create_table "teacher_experiences", force: :cascade do |t|
    t.string  "teacher_id",      limit: 64
    t.string  "experience_type", limit: 32,              null: false
    t.string  "name",            limit: 200,             null: false
    t.string  "organization",    limit: 200,             null: false
    t.integer "start_year",      limit: 2,   default: 0, null: false
    t.integer "end_year",        limit: 2
  end

  create_table "teacher_intents", force: :cascade do |t|
    t.string   "user_id",    limit: 64,                   null: false
    t.string   "teacher_id", limit: 64,                   null: false
    t.string   "intent",     limit: 64
    t.datetime "created_at",            default: "now()", null: false
    t.datetime "updated_at",            default: "now()", null: false
  end

  add_index "teacher_intents", ["teacher_id", "intent"], name: "teacher_intents_intent_idx", using: :btree

  create_table "teacher_payments", force: :cascade do |t|
    t.string   "teacher_id",      limit: 64,                   null: false
    t.string   "charge_id",       limit: 64,                   null: false
    t.integer  "amount_in_cents",                              null: false
    t.integer  "fee_in_cents",                                 null: false
    t.datetime "created_at",                 default: "now()", null: false
    t.datetime "updated_at",                 default: "now()", null: false
    t.integer  "school_id"
    t.integer  "retailer_id"
  end

  create_table "teachers", force: :cascade do |t|
    t.string   "introductory_video",         limit: 1024
    t.integer  "years_teaching",             limit: 2,                            default: 0,       null: false
    t.integer  "years_playing",              limit: 2,                            default: 0,       null: false
    t.integer  "teaches_age_lower",          limit: 2,                            default: 0,       null: false
    t.integer  "teaches_age_upper",          limit: 2,                            default: 0,       null: false
    t.boolean  "teaches_beginner",                                                default: false,   null: false
    t.boolean  "teaches_intermediate",                                            default: false,   null: false
    t.boolean  "teaches_advanced",                                                default: false,   null: false
    t.string   "website",                    limit: 1024
    t.string   "biography",                  limit: 4096
    t.boolean  "prices_per_lesson",                                               default: false,   null: false
    t.boolean  "prices_per_month",                                                default: false,   null: false
    t.boolean  "lesson_duration_30",                                              default: false,   null: false
    t.boolean  "lesson_duration_45",                                              default: false,   null: false
    t.boolean  "lesson_duration_60",                                              default: false,   null: false
    t.boolean  "lesson_duration_90",                                              default: false,   null: false
    t.boolean  "lesson_duration_120",                                             default: false,   null: false
    t.integer  "price_per_lesson_30_cents"
    t.integer  "price_per_lesson_45_cents"
    t.integer  "price_per_lesson_60_cents"
    t.integer  "price_per_lesson_90_cents"
    t.integer  "price_per_lesson_120_cents"
    t.integer  "price_per_month_30_cents"
    t.integer  "price_per_month_45_cents"
    t.integer  "price_per_month_60_cents"
    t.integer  "price_per_month_90_cents"
    t.integer  "price_per_month_120_cents"
    t.datetime "created_at",                                                      default: "now()", null: false
    t.datetime "updated_at",                                                      default: "now()", null: false
    t.integer  "test_drives_per_week",                                            default: 2,       null: false
    t.boolean  "teaches_test_drive",                                              default: true,    null: false
    t.datetime "background_check_at"
    t.datetime "ready_for_session_at"
    t.boolean  "top_rated",                                                       default: false,   null: false
    t.decimal  "profile_pct",                             precision: 8, scale: 2
    t.json     "profile_pct_summary"
    t.integer  "school_id"
    t.datetime "joined_school_at"
    t.decimal  "jamkazam_rate",                           precision: 8, scale: 2, default: 0.25
    t.string   "short_bio"
    t.integer  "retailer_id"
    t.datetime "joined_retailer_at"
    t.boolean  "is_searchable",                                                   default: true,    null: false
    t.integer  "random_order",                                                    default: 0,       null: false
  end

  create_table "teachers_genres", id: false, force: :cascade do |t|
    t.string "teacher_id", limit: 64
    t.string "genre_id",   limit: 64
  end

  create_table "teachers_instruments", id: false, force: :cascade do |t|
    t.string "teacher_id",    limit: 64
    t.string "instrument_id", limit: 64
  end

  create_table "teachers_languages", id: false, force: :cascade do |t|
    t.string "teacher_id",  limit: 64
    t.string "language_id", limit: 64
  end

  create_table "teachers_subjects", id: false, force: :cascade do |t|
    t.string "teacher_id", limit: 64
    t.string "subject_id", limit: 64
  end

  create_table "test_drive_package_choice_teachers", force: :cascade do |t|
    t.string   "test_drive_package_choice_id", limit: 64
    t.string   "teacher_id",                   limit: 64
    t.datetime "created_at",                              default: "now()", null: false
    t.datetime "updated_at",                              default: "now()", null: false
  end

  create_table "test_drive_package_choices", force: :cascade do |t|
    t.string   "test_drive_package_id", limit: 64
    t.string   "user_id",               limit: 64
    t.datetime "created_at",                       default: "now()", null: false
    t.datetime "updated_at",                       default: "now()", null: false
  end

  create_table "test_drive_package_teachers", force: :cascade do |t|
    t.string   "user_id",               limit: 64
    t.string   "test_drive_package_id", limit: 64
    t.datetime "created_at",                       default: "now()", null: false
    t.datetime "updated_at",                       default: "now()", null: false
    t.string   "short_bio"
  end

  create_table "test_drive_packages", force: :cascade do |t|
    t.string   "name",                           null: false
    t.string   "package_type",                   null: false
    t.string   "description"
    t.datetime "created_at",   default: "now()", null: false
    t.datetime "updated_at",   default: "now()", null: false
  end

  add_index "test_drive_packages", ["name"], name: "test_drive_packages_name_key", unique: true, using: :btree

  create_table "text_messages", force: :cascade do |t|
    t.string   "source_user_id", limit: 64
    t.string   "target_user_id", limit: 64
    t.text     "message",                                     null: false
    t.datetime "created_at",                default: "now()", null: false
    t.datetime "updated_at",                default: "now()", null: false
  end

  create_table "tracks", force: :cascade do |t|
    t.string   "connection_id",      limit: 64,                    null: false
    t.string   "instrument_id",      limit: 64
    t.string   "sound",              limit: 64,                    null: false
    t.datetime "created_at",                     default: "now()", null: false
    t.datetime "updated_at",                     default: "now()", null: false
    t.string   "client_track_id",    limit: 64,                    null: false
    t.string   "client_resource_id", limit: 100
  end

  create_table "user_authorizations", force: :cascade do |t|
    t.string   "user_id",          limit: 64
    t.string   "uid",              limit: 255,                    null: false
    t.string   "provider",         limit: 255,                    null: false
    t.string   "token",            limit: 2000
    t.datetime "token_expiration"
    t.datetime "created_at",                    default: "now()", null: false
    t.datetime "updated_at",                    default: "now()", null: false
    t.string   "secret",           limit: 255
    t.string   "refresh_token"
  end

  add_index "user_authorizations", ["provider", "uid"], name: "user_authorizations_uniqkey", unique: true, using: :btree
  add_index "user_authorizations", ["user_id"], name: "user_authorizations_user_id_idx", using: :btree

  create_table "user_blacklists", force: :cascade do |t|
    t.string   "user_id",    limit: 64,                   null: false
    t.string   "notes"
    t.datetime "created_at",            default: "now()", null: false
    t.datetime "updated_at",            default: "now()", null: false
  end

  add_index "user_blacklists", ["user_id"], name: "user_blacklists_user_id_key", unique: true, using: :btree

  create_table "user_events", force: :cascade do |t|
    t.string   "user_id",    limit: 64
    t.string   "name",       limit: 100,                   null: false
    t.json     "detail"
    t.datetime "created_at",             default: "now()", null: false
  end

  create_table "user_whitelists", force: :cascade do |t|
    t.string   "user_id",    limit: 64,                   null: false
    t.string   "notes"
    t.datetime "created_at",            default: "now()", null: false
    t.datetime "updated_at",            default: "now()", null: false
  end

  add_index "user_whitelists", ["user_id"], name: "user_whitelists_user_id_key", unique: true, using: :btree

  create_table "users", force: :cascade do |t|
    t.string   "email",                                limit: 255,                         null: false
    t.string   "remember_token",                       limit: 255
    t.string   "encrypted_password",                   limit: 255,                         null: false
    t.boolean  "admin",                                             default: false,        null: false
    t.datetime "created_at",                                        default: "now()",      null: false
    t.datetime "updated_at",                                        default: "now()",      null: false
    t.boolean  "musician",                                          default: false,        null: false
    t.string   "city",                                 limit: 100
    t.string   "state",                                limit: 100
    t.string   "country",                              limit: 100
    t.string   "first_name",                           limit: 50
    t.string   "last_name",                            limit: 50
    t.date     "birth_date"
    t.string   "gender",                               limit: 1
    t.string   "signup_token",                         limit: 255
    t.boolean  "email_confirmed",                                   default: false
    t.string   "photo_url",                            limit: 2048
    t.string   "session_settings",                     limit: 4000
    t.string   "reset_password_token",                 limit: 64
    t.datetime "reset_password_token_created"
    t.boolean  "can_invite",                                        default: true,         null: false
    t.tsvector "name_tsv"
    t.string   "environment",                          limit: 255,  default: "public",     null: false
    t.boolean  "subscribe_email",                                   default: true
    t.string   "update_email",                         limit: 1024
    t.string   "update_email_token",                   limit: 1024
    t.string   "original_fpfile",                      limit: 8000
    t.string   "cropped_fpfile",                       limit: 8000
    t.string   "cropped_s3_path",                      limit: 512
    t.string   "crop_selection",                       limit: 256
    t.datetime "last_failed_certified_gear_at"
    t.string   "last_failed_certified_gear_reason",    limit: 256
    t.datetime "first_downloaded_client_at"
    t.datetime "first_ran_client_at"
    t.datetime "first_certified_gear_at"
    t.datetime "first_music_session_at"
    t.datetime "first_real_music_session_at"
    t.datetime "first_good_music_session_at"
    t.datetime "first_invited_at"
    t.datetime "first_friended_at"
    t.datetime "first_social_promoted_at"
    t.boolean  "show_whats_next",                                   default: true
    t.text     "biography"
    t.string   "icecast_server_group_id",              limit: 64,   default: "default",    null: false
    t.datetime "first_recording_at"
    t.string   "large_photo_url",                      limit: 2048
    t.string   "cropped_large_s3_path",                limit: 512
    t.string   "cropped_large_fpfile",                 limit: 8000
    t.datetime "notification_seen_at"
    t.json     "mods"
    t.float    "last_jam_audio_latency"
    t.integer  "last_jam_addr",                        limit: 8
    t.integer  "last_jam_locidispid",                  limit: 8
    t.string   "last_jam_updated_reason",              limit: 1
    t.datetime "last_jam_updated_at"
    t.string   "statecode",                            limit: 2
    t.string   "countrycode",                          limit: 2
    t.string   "recurly_code",                         limit: 50
    t.boolean  "online",                                            default: false,        null: false
    t.string   "website",                              limit: 4000
    t.integer  "skill_level",                          limit: 2
    t.integer  "concert_count",                        limit: 2
    t.integer  "studio_session_count",                 limit: 2
    t.boolean  "virtual_band",                                      default: false,        null: false
    t.integer  "virtual_band_commitment",              limit: 2
    t.boolean  "traditional_band",                                  default: false,        null: false
    t.integer  "traditional_band_commitment",          limit: 2
    t.boolean  "traditional_band_touring"
    t.boolean  "paid_sessions",                                     default: false,        null: false
    t.integer  "paid_sessions_hourly_rate"
    t.integer  "paid_sessions_daily_rate"
    t.boolean  "free_sessions",                                     default: false,        null: false
    t.boolean  "cowriting",                                         default: false,        null: false
    t.integer  "cowriting_purpose",                    limit: 2
    t.boolean  "reuse_card",                                        default: true,         null: false
    t.boolean  "has_redeemable_jamtrack",                           default: true,         null: false
    t.integer  "show_whats_next_count",                             default: 0,            null: false
    t.boolean  "want_jamblaster",                                   default: false,        null: false
    t.datetime "first_played_jamtrack_at"
    t.integer  "affiliate_referral_id"
    t.datetime "first_opened_jamtrack_web_player"
    t.integer  "gifted_jamtracks",                                  default: 0
    t.boolean  "email_needs_verification",                          default: false
    t.json     "kickbox_response"
    t.boolean  "bounced",                                           default: false
    t.string   "teacher_id",                           limit: 64
    t.boolean  "is_a_student",                                      default: false,        null: false
    t.boolean  "is_a_teacher",                                      default: false,        null: false
    t.datetime "ready_for_session_at"
    t.integer  "remaining_free_lessons",                            default: 1,            null: false
    t.boolean  "stored_credit_card",                                default: false,        null: false
    t.integer  "remaining_test_drives",                             default: 0,            null: false
    t.string   "stripe_token",                         limit: 200
    t.string   "stripe_customer_id",                   limit: 200
    t.string   "stripe_zip_code",                      limit: 200
    t.integer  "school_id"
    t.datetime "joined_school_at"
    t.boolean  "school_interest",                                   default: false
    t.string   "lesson_package_type_id",               limit: 64
    t.boolean  "phantom",                                           default: false,        null: false
    t.string   "origin_utm_source",                                 default: "legacy"
    t.string   "origin_utm_medium"
    t.string   "origin_utm_campaign"
    t.string   "origin_referrer"
    t.integer  "jamclass_credits",                                  default: 0
    t.boolean  "education_interest",                                default: false,        null: false
    t.boolean  "retailer_interest",                                 default: false,        null: false
    t.string   "lesson_package_needs_purchase_id",     limit: 64
    t.boolean  "under_13"
    t.boolean  "via_amazon"
    t.boolean  "is_onboarder",                                      default: false,        null: false
    t.string   "onboarding_status",                                 default: "Unassigned"
    t.string   "onboarding_lost_reason"
    t.date     "onboarding_lost_at"
    t.string   "onboarding_escalation_reason"
    t.date     "onboarding_escalated_at"
    t.string   "onboarder_id",                         limit: 64
    t.date     "onboarder_assigned_at"
    t.date     "onboarding_email_1_sent_at"
    t.date     "onboarding_email_2_sent_at"
    t.date     "onboarding_email_3_sent_at"
    t.date     "onboarding_email_4_sent_at"
    t.date     "onboarding_email_5_sent_at"
    t.date     "onboarding_test_session_scheduled_at"
    t.datetime "onboarding_test_session_at"
    t.string   "onboarding_test_session_outcome"
    t.date     "onboarding_onboarded_at"
    t.string   "onboarding_onboarder_notes"
    t.datetime "first_onboarding_free_lesson_at"
    t.datetime "first_onboarding_paid_lesson_at"
    t.string   "timezone"
    t.boolean  "deleted",                                           default: false,        null: false
    t.integer  "max_onboardings",                                   default: 0,            null: false
    t.datetime "sent_take_flesson_email_at"
    t.integer  "sent_take_flesson_email_times",                     default: 0,            null: false
    t.datetime "sent_take_2nd_flesson_email_at"
    t.integer  "sent_take_2nd_flesson_email_times",                 default: 0,            null: false
    t.datetime "sent_take_plesson_email_at"
    t.integer  "sent_take_plesson_email_times",                     default: 0,            null: false
    t.datetime "second_onboarding_free_lesson_at"
    t.datetime "sent_admin_take_flesson_email_at"
    t.datetime "sent_admin_take_2nd_flesson_email_at"
    t.datetime "sent_admin_take_plesson_email_at"
    t.boolean  "stuck_take_flesson",                                default: false,        null: false
    t.boolean  "stuck_take_2nd_flesson",                            default: false,        null: false
    t.boolean  "stuck_take_plesson",                                default: false,        null: false
    t.boolean  "send_onboarding_survey",                            default: false,        null: false
    t.datetime "sent_onboarding_survey_at"
    t.datetime "first_lesson_booked_at"
    t.integer  "remind_take_lesson_times",                          default: 0,            null: false
    t.datetime "remind_take_lesson_at"
    t.datetime "sent_first_lesson_instr_email_at"
    t.boolean  "beta",                                              default: false
    t.boolean  "is_platform_instructor",                            default: false,        null: false
    t.string   "import_source",                        limit: 50
    t.date     "license_start"
    t.date     "license_end"
    t.string   "recurly_subscription_id",              limit: 100
    t.string   "recurly_token",                        limit: 200
    t.string   "recurly_subscription_state",           limit: 20
    t.string   "subscription_plan_code",               limit: 100
    t.string   "desired_plan_code",                    limit: 100
    t.string   "admin_override_plan_code",             limit: 100
    t.date     "admin_override_ends_at"
    t.string   "admin_override_reason"
    t.datetime "desired_plan_code_set_at"
    t.datetime "subscription_plan_code_set_at"
    t.datetime "subscription_last_checked_at"
    t.string   "subscription_sync_code"
    t.string   "subscription_sync_msg"
    t.string   "client_fingerprint",                   limit: 255
    t.boolean  "is_past_due",                                       default: false
    t.datetime "subscription_trial_ends_at",                        default: "now()",      null: false
    t.string   "subscription_plan_reason",             limit: 20
    t.integer  "used_current_month"
    t.integer  "used_month_play_time"
  end

  add_index "users", ["affiliate_referral_id"], name: "index_users_on_affiliate_referral_id", using: :btree
  add_index "users", ["created_at"], name: "index_users_on_created_at", using: :btree
  add_index "users", ["email"], name: "trgm_idx_users_email", using: :gin
  add_index "users", ["email"], name: "users_email_key", unique: true, using: :btree
  add_index "users", ["first_onboarding_paid_lesson_at"], name: "index_first_onboarding_paid_lesson_at", using: :btree
  add_index "users", ["last_jam_locidispid"], name: "users_last_jam_locidispid_ndx", using: :btree
  add_index "users", ["name_tsv"], name: "users_name_tsv_index", using: :gin
  add_index "users", ["onboarding_onboarded_at"], name: "index_onboarding_onboarded_at", using: :btree
  add_index "users", ["onboarding_status"], name: "index_onboarding_status", using: :btree
  add_index "users", ["remember_token"], name: "remember_token_idx", using: :btree
  add_index "users", ["remember_token"], name: "users_remember_token_key", unique: true, using: :btree
  add_index "users", ["remind_take_lesson_times"], name: "index_remind_take_lesson_times", using: :btree
  add_index "users", ["school_id"], name: "users_schood_id_idx", using: :btree
  add_index "users", ["sent_admin_take_2nd_flesson_email_at"], name: "index_sent_admin_take_2nd_flesson_email_at", using: :btree
  add_index "users", ["sent_admin_take_flesson_email_at"], name: "index_sent_admin_take_flesson_email_at", using: :btree
  add_index "users", ["sent_admin_take_plesson_email_at"], name: "index_sent_admin_take_plesson_email_at", using: :btree
  add_index "users", ["sent_first_lesson_instr_email_at"], name: "index_sent_first_lesson_instr_email_at", using: :btree
  add_index "users", ["signup_token"], name: "users_signup_token_key", unique: true, using: :btree
  add_index "users", ["stuck_take_2nd_flesson"], name: "index_stuck_take_2nd_flesson", using: :btree
  add_index "users", ["stuck_take_flesson"], name: "index_stuck_take_flesson", using: :btree
  add_index "users", ["stuck_take_plesson"], name: "index_stuck_take_plesson", using: :btree
  add_index "users", ["subscribe_email", "musician"], name: "users_musician_email_idx", using: :btree
  add_index "users", ["subscription_sync_code"], name: "subscription_sync_code_user_index", using: :btree
  add_index "users", ["update_email_token"], name: "users_update_email_token_key", unique: true, using: :btree

  create_table "video_sources", force: :cascade do |t|
    t.string   "connection_id",          limit: 64,                   null: false
    t.string   "client_video_source_id", limit: 64,                   null: false
    t.datetime "created_at",                        default: "now()", null: false
    t.datetime "updated_at",                        default: "now()", null: false
  end

  add_foreign_key "active_music_sessions", "schools", name: "active_music_sessions_school_id_fkey"
  add_foreign_key "affiliate_distributions", "affiliate_partners", column: "affiliate_referral_id", name: "affiliate_distributions_affiliate_referral_id_fkey"
  add_foreign_key "affiliate_distributions", "sale_line_items", name: "affiliate_distributions_sale_line_item_id_fkey"
  add_foreign_key "affiliate_monthly_payments", "affiliate_partners", name: "affiliate_monthly_payments_affiliate_partner_id_fkey"
  add_foreign_key "affiliate_partners", "users", column: "partner_user_id", name: "affiliate_partners_partner_user_id_fkey", on_delete: :nullify
  add_foreign_key "affiliate_quarterly_payments", "affiliate_partners", name: "affiliate_quarterly_payments_affiliate_partner_id_fkey"
  add_foreign_key "affiliate_traffic_totals", "affiliate_partners", name: "affiliate_traffic_totals_affiliate_partner_id_fkey"
  add_foreign_key "backing_tracks", "connections", name: "backing_tracks_connection_id_fkey", on_delete: :cascade
  add_foreign_key "band_invitations", "bands", name: "band_invitations_band_id_fkey", on_delete: :cascade
  add_foreign_key "band_invitations", "users", column: "creator_id", name: "band_invitations_creator_id_fkey", on_delete: :cascade
  add_foreign_key "band_invitations", "users", name: "band_invitations_user_id_fkey", on_delete: :cascade
  add_foreign_key "bands_musicians", "bands", name: "bands_musicians_band_id_fkey", on_delete: :cascade
  add_foreign_key "bands_musicians", "users", name: "bands_musicians_user_id_fkey", on_delete: :cascade
  add_foreign_key "broadcast_notification_views", "broadcast_notifications", name: "broadcast_notification_views_broadcast_notification_id_fkey", on_delete: :cascade
  add_foreign_key "broadcast_notification_views", "users", name: "broadcast_notification_views_user_id_fkey", on_delete: :cascade
  add_foreign_key "broadcasts", "music_sessions", name: "broadcasts_music_session_id_fkey", on_delete: :cascade
  add_foreign_key "broadcasts", "users", name: "broadcasts_user_id_fkey", on_delete: :cascade
  add_foreign_key "calendars", "users", name: "calendars_user_id_fkey", on_delete: :cascade
  add_foreign_key "charges", "users", name: "charges_user_id_fkey"
  add_foreign_key "chat_messages", "claimed_recordings", name: "chat_messages_claimed_recording_id_fkey"
  add_foreign_key "chat_messages", "lesson_sessions", name: "chat_messages_lesson_session_id_fkey", on_delete: :cascade
  add_foreign_key "chat_messages", "lesson_sessions", name: "chat_messages_target_user_id_fkey", on_delete: :nullify
  add_foreign_key "chat_messages", "music_notations", name: "chat_messages_music_notation_id_fkey"
  add_foreign_key "chat_messages", "users", name: "chat_messages_user_id_fkey", on_delete: :cascade
  add_foreign_key "claimed_recordings", "genres", name: "claimed_recordings_genre_id_fkey"
  add_foreign_key "claimed_recordings", "recordings", name: "musicians_recordings_recording_id_fkey", on_delete: :cascade
  add_foreign_key "claimed_recordings", "users", name: "musicians_recordings_user_id_fkey", on_delete: :cascade
  add_foreign_key "client_live_streams", "music_sessions", name: "client_live_streams_music_session_id_fkey", on_delete: :cascade
  add_foreign_key "client_live_streams", "users", name: "client_live_streams_user_id_fkey", on_delete: :cascade
  add_foreign_key "connections", "active_music_sessions", column: "music_session_id", name: "connections_music_session_id_fkey", on_delete: :nullify
  add_foreign_key "crash_dumps", "users", name: "crash_dumps_user_id_fkey", on_delete: :nullify
  add_foreign_key "diagnostics", "users", name: "diagnostics_user_id_fkey", on_delete: :cascade
  add_foreign_key "download_trackers", "jam_tracks", name: "download_trackers_jam_track_id_fkey", on_delete: :cascade
  add_foreign_key "download_trackers", "users", name: "download_trackers_user_id_fkey", on_delete: :cascade
  add_foreign_key "email_batch_sets", "email_batches", name: "email_batch_sets_email_batch_id_fkey", on_delete: :cascade
  add_foreign_key "email_errors", "users", name: "email_errors_user_id_fkey", on_delete: :cascade
  add_foreign_key "event_brite_orders", "event_brite_order_uploads", name: "event_brite_orders_event_brite_order_upload_id_fkey", on_delete: :cascade
  add_foreign_key "event_brite_orders", "live_streams", name: "event_brite_orders_live_stream_id_fkey", on_delete: :cascade
  add_foreign_key "event_sessions", "bands", name: "event_sessions_band_id_fkey", on_delete: :nullify
  add_foreign_key "event_sessions", "events", name: "event_sessions_event_id_fkey", on_delete: :cascade
  add_foreign_key "event_sessions", "users", name: "event_sessions_user_id_fkey", on_delete: :nullify
  add_foreign_key "fan_invitations", "music_sessions", name: "fan_invitations_music_session_id_fkey", on_delete: :cascade
  add_foreign_key "feeds", "music_sessions", name: "feeds_music_session_id_fkey", on_delete: :cascade
  add_foreign_key "feeds", "recordings", name: "feeds_recording_id_fkey", on_delete: :cascade
  add_foreign_key "follows", "users", name: "follows_user_fkey", on_delete: :cascade
  add_foreign_key "fraud_alerts", "machine_fingerprints", name: "fraud_alerts_machine_fingerprint_id_fkey", on_delete: :cascade
  add_foreign_key "fraud_alerts", "users", name: "fraud_alerts_user_id_fkey", on_delete: :cascade
  add_foreign_key "friend_requests", "users", column: "friend_id", name: "friend_requests_friend_id_fkey", on_delete: :cascade
  add_foreign_key "friend_requests", "users", name: "friend_requests_user_id_fkey", on_delete: :cascade
  add_foreign_key "friendships", "users", column: "friend_id", name: "friendships_friend_id_fkey", on_delete: :cascade
  add_foreign_key "friendships", "users", name: "friendships_user_id_fkey", on_delete: :cascade
  add_foreign_key "genre_players", "genres", name: "bands_genres_genre_id_fkey", on_delete: :cascade
  add_foreign_key "genres_jam_tracks", "genres", name: "genres_jam_tracks_genre_id_fkey", on_delete: :cascade
  add_foreign_key "genres_jam_tracks", "jam_tracks", name: "genres_jam_tracks_jam_track_id_fkey", on_delete: :cascade
  add_foreign_key "genres_music_sessions", "active_music_sessions", column: "music_session_id", name: "genres_music_sessions_music_session_id_fkey", on_delete: :cascade
  add_foreign_key "gift_card_purchases", "gift_card_types", name: "gift_card_purchases_gift_card_type_id_fkey", on_delete: :nullify
  add_foreign_key "gift_card_purchases", "users", name: "gift_card_purchases_user_id_fkey", on_delete: :nullify
  add_foreign_key "gift_cards", "users", name: "gift_cards_user_id_fkey", on_delete: :cascade
  add_foreign_key "icecast_mounts", "active_music_sessions", column: "music_session_id", name: "icecast_mounts_music_session_id_fkey", on_delete: :cascade
  add_foreign_key "icecast_mounts", "icecast_mount_templates", name: "icecast_mounts_icecast_mount_template_id_fkey", on_delete: :nullify
  add_foreign_key "icecast_mounts", "icecast_servers", name: "icecast_mounts_icecast_server_id_fkey", on_delete: :nullify
  add_foreign_key "icecast_server_mounts", "icecast_servers", name: "icecast_server_mounts_icecast_server_id_fkey", on_delete: :cascade
  add_foreign_key "icecast_server_relays", "icecast_relays", name: "icecast_server_relays_icecast_relay_id_fkey", on_delete: :cascade
  add_foreign_key "icecast_server_relays", "icecast_servers", name: "icecast_server_relays_icecast_server_id_fkey", on_delete: :cascade
  add_foreign_key "icecast_server_sockets", "icecast_listen_sockets", name: "icecast_server_sockets_icecast_listen_socket_id_fkey", on_delete: :cascade
  add_foreign_key "icecast_server_sockets", "icecast_servers", name: "icecast_server_sockets_icecast_server_id_fkey", on_delete: :cascade
  add_foreign_key "icecast_servers", "icecast_admin_authentications", column: "admin_auth_id", name: "icecast_servers_admin_auth_id_fkey", on_delete: :nullify
  add_foreign_key "icecast_servers", "icecast_directories", column: "directory_id", name: "icecast_servers_directory_id_fkey", on_delete: :nullify
  add_foreign_key "icecast_servers", "icecast_limits", column: "limit_id", name: "icecast_servers_limit_id_fkey", on_delete: :nullify
  add_foreign_key "icecast_servers", "icecast_loggings", column: "logging_id", name: "icecast_servers_logging_id_fkey", on_delete: :nullify
  add_foreign_key "icecast_servers", "icecast_master_server_relays", column: "master_relay_id", name: "icecast_servers_master_relay_id_fkey", on_delete: :nullify
  add_foreign_key "icecast_servers", "icecast_mount_templates", column: "mount_template_id", name: "icecast_servers_mount_template_id_fkey", on_delete: :nullify
  add_foreign_key "icecast_servers", "icecast_paths", column: "path_id", name: "icecast_servers_path_id_fkey", on_delete: :nullify
  add_foreign_key "icecast_servers", "icecast_securities", column: "security_id", name: "icecast_servers_security_id_fkey", on_delete: :nullify
  add_foreign_key "icecast_servers", "icecast_server_groups", name: "icecast_servers_icecast_server_group_id_fkey", on_delete: :nullify
  add_foreign_key "icecast_servers", "icecast_templates", column: "template_id", name: "icecast_servers_template_id_fkey", on_delete: :nullify
  add_foreign_key "icecast_source_changes", "icecast_mounts", name: "icecast_source_changes_icecast_mount_id_fkey", on_delete: :cascade
  add_foreign_key "icecast_template_sockets", "icecast_listen_sockets", name: "icecast_template_sockets_icecast_listen_socket_id_fkey", on_delete: :cascade
  add_foreign_key "icecast_template_sockets", "icecast_templates", name: "icecast_template_sockets_icecast_template_id_fkey", on_delete: :cascade
  add_foreign_key "icecast_templates", "icecast_admin_authentications", column: "admin_auth_id", name: "icecast_templates_admin_auth_id_fkey", on_delete: :nullify
  add_foreign_key "icecast_templates", "icecast_directories", column: "directory_id", name: "icecast_templates_directory_id_fkey", on_delete: :nullify
  add_foreign_key "icecast_templates", "icecast_limits", column: "limit_id", name: "icecast_templates_limit_id_fkey", on_delete: :nullify
  add_foreign_key "icecast_templates", "icecast_loggings", column: "logging_id", name: "icecast_templates_logging_id_fkey", on_delete: :nullify
  add_foreign_key "icecast_templates", "icecast_master_server_relays", column: "master_relay_id", name: "icecast_templates_master_relay_id_fkey", on_delete: :nullify
  add_foreign_key "icecast_templates", "icecast_paths", column: "path_id", name: "icecast_templates_path_id_fkey", on_delete: :nullify
  add_foreign_key "icecast_templates", "icecast_securities", column: "security_id", name: "icecast_templates_security_id_fkey", on_delete: :nullify
  add_foreign_key "invitations", "join_requests", name: "invitations_join_request_id_fkey", on_delete: :cascade
  add_foreign_key "invitations", "music_sessions", name: "invitations_music_session_id_fkey", on_delete: :cascade
  add_foreign_key "invited_users", "users", column: "receiver_id", name: "invited_users_receiver_id_fkey"
  add_foreign_key "invited_users", "users", column: "sender_id", name: "invited_users_sender_id_fkey", on_delete: :cascade
  add_foreign_key "jam_track_files", "jam_tracks", name: "jam_track_files_jam_track_id_fkey", on_delete: :cascade
  add_foreign_key "jam_track_hfa_request_ids", "jam_track_hfa_requests", name: "jam_track_hfa_request_ids_jam_track_hfa_request_id_fkey", on_delete: :nullify
  add_foreign_key "jam_track_hfa_request_ids", "jam_tracks", name: "jam_track_hfa_request_ids_jam_track_id_fkey", on_delete: :nullify
  add_foreign_key "jam_track_mixdown_packages", "jam_track_mixdowns", name: "jam_track_mixdown_packages_jam_track_mixdown_id_fkey", on_delete: :cascade
  add_foreign_key "jam_track_mixdowns", "jam_tracks", name: "jam_track_mixdowns_jam_track_id_fkey", on_delete: :cascade
  add_foreign_key "jam_track_mixdowns", "users", name: "jam_track_mixdowns_user_id_fkey", on_delete: :cascade
  add_foreign_key "jam_track_rights", "jam_track_mixdowns", column: "last_mixdown_id", name: "jam_track_rights_last_mixdown_id_fkey", on_delete: :nullify
  add_foreign_key "jam_track_rights", "jam_track_tracks", column: "last_stem_id", name: "jam_track_rights_last_stem_id_fkey", on_delete: :nullify
  add_foreign_key "jam_track_rights", "jam_tracks", name: "jam_track_rights_jam_track_id_fkey"
  add_foreign_key "jam_track_rights", "users", name: "jam_track_rights_user_id_fkey", on_delete: :cascade
  add_foreign_key "jam_track_sessions", "jam_tracks", name: "jam_track_sessions_jam_track_id_fkey", on_delete: :cascade
  add_foreign_key "jam_track_sessions", "music_sessions", name: "jam_track_sessions_music_session_id_fkey", on_delete: :nullify
  add_foreign_key "jam_track_sessions", "users", name: "jam_track_sessions_user_id_fkey"
  add_foreign_key "jam_track_tap_ins", "jam_tracks", name: "jam_track_tap_ins_jam_track_id_fkey", on_delete: :cascade
  add_foreign_key "jam_track_tracks", "instruments", name: "jam_track_tracks_instrument_id_fkey", on_delete: :nullify
  add_foreign_key "jam_track_tracks", "jam_tracks", name: "jam_track_tracks_jam_track_id_fkey", on_delete: :cascade
  add_foreign_key "jam_tracks", "jam_track_licensors", column: "licensor_id", name: "jam_tracks_licensor_id_fkey", on_delete: :nullify
  add_foreign_key "jamblaster_pairing_requests", "jamblasters", name: "jamblaster_pairing_requests_jamblaster_id_fkey", on_delete: :cascade
  add_foreign_key "jamblaster_pairing_requests", "users", name: "jamblaster_pairing_requests_user_id_fkey", on_delete: :cascade
  add_foreign_key "jamblasters", "users", name: "jamblasters_user_id_fkey", on_delete: :nullify
  add_foreign_key "jamblasters_users", "jamblasters", name: "jamblasters_users_jamblaster_id_fkey", on_delete: :cascade
  add_foreign_key "jamblasters_users", "users", name: "jamblasters_users_user_id_fkey", on_delete: :cascade
  add_foreign_key "join_requests", "music_sessions", name: "join_requests_music_session_id_fkey", on_delete: :cascade
  add_foreign_key "json_stores", "users", name: "json_stores_user_id_fkey", on_delete: :cascade
  add_foreign_key "lesson_booking_slots", "lesson_bookings", name: "lesson_booking_slots_lesson_booking_id_fkey", on_delete: :nullify
  add_foreign_key "lesson_booking_slots", "lesson_sessions", name: "lesson_booking_slots_lesson_session_id_fkey"
  add_foreign_key "lesson_booking_slots", "users", column: "proposer_id", name: "lesson_booking_slots_proposer_id_fkey"
  add_foreign_key "lesson_bookings", "lesson_booking_slots", column: "counter_slot_id", name: "lesson_bookings_counter_slot_id_fkey", on_delete: :cascade
  add_foreign_key "lesson_bookings", "lesson_booking_slots", column: "default_slot_id", name: "lesson_bookings_default_slot_id_fkey", on_delete: :cascade
  add_foreign_key "lesson_bookings", "retailers", name: "lesson_bookings_retailer_id_fkey"
  add_foreign_key "lesson_bookings", "schools", name: "lesson_bookings_school_id_fkey"
  add_foreign_key "lesson_bookings", "test_drive_package_choices", name: "lesson_bookings_test_drive_package_choice_id_fkey"
  add_foreign_key "lesson_bookings", "test_drive_packages", name: "lesson_bookings_test_drive_package_id_fkey"
  add_foreign_key "lesson_bookings", "users", column: "accepter_id", name: "lesson_bookings_accepter_id_fkey"
  add_foreign_key "lesson_bookings", "users", column: "canceler_id", name: "lesson_bookings_canceler_id_fkey"
  add_foreign_key "lesson_bookings", "users", column: "counterer_id", name: "lesson_bookings_counterer_id_fkey"
  add_foreign_key "lesson_bookings", "users", column: "teacher_id", name: "lesson_bookings_teacher_id_fkey"
  add_foreign_key "lesson_bookings", "users", name: "lesson_bookings_user_id_fkey"
  add_foreign_key "lesson_package_purchases", "charges", name: "lesson_package_purchases_charge_id_fkey"
  add_foreign_key "lesson_package_purchases", "lesson_bookings", name: "lesson_package_purchases_lesson_booking_id_fkey", on_delete: :nullify
  add_foreign_key "lesson_package_purchases", "lesson_package_types", name: "lesson_package_purchases_lesson_package_type_id_fkey"
  add_foreign_key "lesson_package_purchases", "users", column: "teacher_id", name: "lesson_package_purchases_teacher_id_fkey"
  add_foreign_key "lesson_package_purchases", "users", name: "lesson_package_purchases_user_id_fkey"
  add_foreign_key "lesson_sessions", "charges", name: "lesson_sessions_charge_id_fkey"
  add_foreign_key "lesson_sessions", "lesson_booking_slots", column: "counter_slot_id", name: "lesson_sessions_counter_slot_id_fkey"
  add_foreign_key "lesson_sessions", "lesson_booking_slots", column: "slot_id", name: "lesson_sessions_slot_id_fkey", on_delete: :cascade
  add_foreign_key "lesson_sessions", "lesson_bookings", name: "lesson_sessions_lesson_booking_id_fkey"
  add_foreign_key "lesson_sessions", "lesson_package_purchases", name: "lesson_sessions_lesson_package_purchase_id_fkey"
  add_foreign_key "lesson_sessions", "users", column: "canceler_id", name: "lesson_sessions_canceler_id_fkey"
  add_foreign_key "lesson_sessions", "users", column: "counterer_id", name: "lesson_sessions_counterer_id_fkey"
  add_foreign_key "lesson_sessions", "users", column: "teacher_id", name: "lesson_sessions_teacher_id_fkey"
  add_foreign_key "lesson_sessions", "users", name: "lesson_sessions_user_id_fkey"
  add_foreign_key "likes", "users", name: "likes_user_fkey", on_delete: :cascade
  add_foreign_key "live_streams", "bands", name: "live_streams_band_id_fkey", on_delete: :nullify
  add_foreign_key "live_streams", "users", name: "live_streams_user_id_fkey", on_delete: :nullify
  add_foreign_key "machine_extras", "machine_fingerprints", name: "machine_extras_machine_fingerprint_id_fkey", on_delete: :cascade
  add_foreign_key "machine_fingerprints", "jam_track_rights", name: "machine_fingerprints_jam_track_right_id_fkey", on_delete: :nullify
  add_foreign_key "machine_fingerprints", "users", name: "machine_fingerprints_user_id_fkey", on_delete: :cascade
  add_foreign_key "mixes", "recordings", name: "mixes_recording_id_fkey", on_delete: :cascade
  add_foreign_key "music_notations", "music_sessions", name: "music_notations_music_session_id_fkey", on_delete: :cascade
  add_foreign_key "music_notations", "users", name: "music_notations_user_id_fkey", on_delete: :cascade
  add_foreign_key "music_sessions", "bands", name: "music_sessions_history_band_id_fkey", on_delete: :cascade
  add_foreign_key "music_sessions", "genres", name: "music_sessions_history_genre_id_fkey"
  add_foreign_key "music_sessions", "lesson_sessions", name: "music_sessions_lesson_session_id_fkey", on_delete: :nullify
  add_foreign_key "music_sessions", "recurring_sessions", name: "music_sessions_history_recurring_session_id_fkey"
  add_foreign_key "music_sessions", "schools", name: "music_sessions_school_id_fkey"
  add_foreign_key "music_sessions", "users", column: "session_controller_id", name: "music_sessions_session_controller_id_fkey"
  add_foreign_key "music_sessions", "users", name: "music_sessions_history_user_id_fkey", on_delete: :cascade
  add_foreign_key "music_sessions_comments", "music_sessions", name: "music_sessions_comments_music_session_id2_fkey", on_delete: :cascade
  add_foreign_key "music_sessions_comments", "users", column: "creator_id", name: "music_sessions_comments_creator_id_fkey", on_delete: :cascade
  add_foreign_key "music_sessions_likers", "music_sessions", name: "music_sessions_likers_music_session_id2_fkey", on_delete: :cascade
  add_foreign_key "music_sessions_likers", "users", column: "liker_id", name: "music_sessions_likers_liker_id_fkey", on_delete: :cascade
  add_foreign_key "music_sessions_user_history", "music_sessions", name: "music_sessions_user_history_music_session_id2_fkey", on_delete: :cascade
  add_foreign_key "music_sessions_user_history", "users", name: "music_sessions_user_history_user_id_fkey", on_delete: :cascade
  add_foreign_key "musicians_instruments", "instruments", name: "musicians_instruments_instrument_id_fkey", on_delete: :cascade
  add_foreign_key "notifications", "band_invitations", name: "notifications_band_invitation_id_fkey", on_delete: :cascade
  add_foreign_key "notifications", "bands", name: "notifications_band_id_fkey", on_delete: :cascade
  add_foreign_key "notifications", "friend_requests", name: "notifications_friend_request_id_fkey"
  add_foreign_key "notifications", "jam_track_mixdown_packages", name: "notifications_jam_track_mixdown_package_id_fkey", on_delete: :cascade
  add_foreign_key "notifications", "jam_track_rights", name: "notifications_jam_track_right_id_fkey", on_delete: :cascade
  add_foreign_key "notifications", "lesson_sessions", name: "notifications_lesson_session_id_fkey", on_delete: :cascade
  add_foreign_key "notifications", "recordings", name: "notifications_recording_id_fkey", on_delete: :cascade
  add_foreign_key "notifications", "users", column: "source_user_id", name: "notifications_source_user_id_fkey", on_delete: :cascade
  add_foreign_key "notifications", "users", column: "target_user_id", name: "notifications_target_user_id_fkey", on_delete: :cascade
  add_foreign_key "performance_samples", "claimed_recordings", name: "performance_samples_claimed_recording_id_fkey", on_delete: :cascade
  add_foreign_key "playable_plays", "claimed_recordings", name: "playable_plays_claimed_recording_id_fkey", on_delete: :cascade
  add_foreign_key "playable_plays", "users", column: "player_id", name: "playable_plays_player_id_fkey", on_delete: :cascade
  add_foreign_key "posa_card_purchases", "posa_card_types", name: "posa_card_purchases_posa_card_type_id_fkey", on_delete: :nullify
  add_foreign_key "posa_card_purchases", "posa_cards", name: "posa_card_purchases_posa_card_id_fkey", on_delete: :nullify
  add_foreign_key "posa_card_purchases", "users", name: "posa_card_purchases_user_id_fkey", on_delete: :nullify
  add_foreign_key "posa_cards", "lesson_package_types", name: "posa_cards_lesson_package_type_id_fkey", on_delete: :nullify
  add_foreign_key "posa_cards", "retailers", name: "posa_cards_retailer_id_fkey", on_delete: :nullify
  add_foreign_key "posa_cards", "users", name: "posa_cards_user_id_fkey", on_delete: :nullify
  add_foreign_key "quick_mixes", "recordings", name: "quick_mixes_recording_id_fkey", on_delete: :cascade
  add_foreign_key "quick_mixes", "users", name: "quick_mixes_user_id_fkey", on_delete: :nullify
  add_foreign_key "recorded_backing_tracks", "users", name: "recorded_backing_tracks_user_id_fkey", on_delete: :cascade
  add_foreign_key "recorded_jam_track_tracks", "jam_track_tracks", name: "recorded_jam_track_tracks_jam_track_track_id_fkey"
  add_foreign_key "recorded_jam_track_tracks", "recordings", name: "recorded_jam_track_tracks_recording_id_fkey"
  add_foreign_key "recorded_jam_track_tracks", "users", name: "recorded_jam_track_tracks_user_id_fkey", on_delete: :cascade
  add_foreign_key "recorded_tracks", "instruments", name: "saved_tracks_instrument_id_fkey", on_delete: :cascade
  add_foreign_key "recorded_tracks", "recordings", name: "recorded_tracks_recording_id_fkey", on_delete: :cascade
  add_foreign_key "recorded_tracks", "users", name: "saved_tracks_user_id_fkey", on_delete: :cascade
  add_foreign_key "recorded_videos", "users", name: "recorded_videos_user_id_fkey", on_delete: :cascade
  add_foreign_key "recordings", "bands", name: "recordings_band_id_fkey"
  add_foreign_key "recordings", "jam_tracks", name: "recordings_jam_track_id_fkey"
  add_foreign_key "recordings", "quick_mixes", column: "first_quick_mix_id", name: "recordings_first_quick_mix_id_fkey", on_delete: :nullify
  add_foreign_key "recordings", "users", column: "jam_track_initiator_id", name: "recordings_jam_track_initiator_id_fkey"
  add_foreign_key "recordings", "users", column: "owner_id", name: "recordings_creator_id_fkey", on_delete: :cascade
  add_foreign_key "recordings_comments", "recordings", name: "recordings_comments_recording_id_fkey", on_delete: :cascade
  add_foreign_key "recordings_comments", "users", column: "creator_id", name: "recordings_comments_creator_id_fkey", on_delete: :cascade
  add_foreign_key "recordings_downloads", "recordings", name: "recordings_downloads_recording_id_fkey", on_delete: :cascade
  add_foreign_key "recordings_downloads", "users", column: "downloader_id", name: "recordings_downloads_downloader_id_fkey", on_delete: :cascade
  add_foreign_key "recordings_likers", "claimed_recordings", name: "recordings_likers_claimed_recording_id_fkey"
  add_foreign_key "recordings_likers", "recordings", name: "recordings_likers_recording_id_fkey", on_delete: :cascade
  add_foreign_key "recordings_likers", "users", column: "liker_id", name: "recordings_likers_liker_id_fkey", on_delete: :cascade
  add_foreign_key "recurly_transaction_web_hooks", "jam_tracks", name: "recurly_transaction_web_hooks_jam_track_id_fkey"
  add_foreign_key "recurly_transaction_web_hooks", "users", name: "recurly_transaction_web_hooks_user_id_fkey", on_delete: :cascade
  add_foreign_key "recurring_sessions", "bands", name: "recurring_sessions_band_id_fkey", on_delete: :cascade
  add_foreign_key "recurring_sessions", "genres", name: "recurring_sessions_genre_id_fkey"
  add_foreign_key "recurring_sessions", "users", name: "recurring_sessions_user_id_fkey", on_delete: :cascade
  add_foreign_key "retailer_invitations", "retailers", name: "retailer_invitations_retailer_id_fkey"
  add_foreign_key "retailer_invitations", "users", name: "retailer_invitations_user_id_fkey"
  add_foreign_key "retailers", "affiliate_partners", name: "retailers_affiliate_partner_id_fkey"
  add_foreign_key "retailers", "users", name: "retailers_user_id_fkey"
  add_foreign_key "reviews", "users", column: "deleted_by_user_id", name: "reviews_deleted_by_user_id_fkey", on_delete: :nullify
  add_foreign_key "reviews", "users", name: "reviews_user_id_fkey", on_delete: :cascade
  add_foreign_key "rsvp_requests", "music_sessions", name: "rsvp_requests_music_session_id_fkey"
  add_foreign_key "rsvp_requests", "users", name: "rsvp_requests_user_id_fkey", on_delete: :cascade
  add_foreign_key "rsvp_requests_rsvp_slots", "rsvp_requests", name: "rsvp_requests_rsvp_slots_rsvp_request_id_fkey", on_delete: :cascade
  add_foreign_key "rsvp_requests_rsvp_slots", "rsvp_slots", name: "rsvp_requests_rsvp_slots_rsvp_slot_id_fkey", on_delete: :cascade
  add_foreign_key "rsvp_slots", "instruments", name: "rsvp_slots_instrument_id_fkey", on_delete: :nullify
  add_foreign_key "rsvp_slots", "music_sessions", name: "rsvp_slots_music_session_id_fkey", on_delete: :cascade
  add_foreign_key "sale_line_items", "affiliate_partners", column: "affiliate_referral_id", name: "sale_line_items_affiliate_referral_id_fkey"
  add_foreign_key "sale_line_items", "gift_card_purchases", name: "sale_line_items_gift_card_purchase_id_fkey"
  add_foreign_key "sale_line_items", "lesson_package_purchases", name: "sale_line_items_lesson_package_purchase_id_fkey"
  add_foreign_key "sale_line_items", "posa_card_purchases", name: "sale_line_items_posa_card_purchase_id_fkey"
  add_foreign_key "sale_line_items", "retailers", name: "sale_line_items_retailer_id_fkey"
  add_foreign_key "sale_line_items", "sales", name: "sale_line_items_sale_id_fkey", on_delete: :cascade
  add_foreign_key "sales", "retailers", name: "sales_retailer_id_fkey"
  add_foreign_key "sales", "users", name: "sales_user_id_fkey", on_delete: :cascade
  add_foreign_key "school_invitations", "schools", name: "school_invitations_school_id_fkey"
  add_foreign_key "school_invitations", "users", name: "school_invitations_user_id_fkey"
  add_foreign_key "schools", "affiliate_partners", name: "schools_affiliate_partner_id_fkey"
  add_foreign_key "schools", "users", name: "schools_user_id_fkey"
  add_foreign_key "session_info_comments", "music_sessions", name: "session_info_comments_music_session_id_fkey", on_delete: :cascade
  add_foreign_key "session_info_comments", "users", column: "creator_id", name: "session_info_comments_creator_id_fkey", on_delete: :cascade
  add_foreign_key "shopping_carts", "users", name: "shopping_carts_user_id_fkey", on_delete: :cascade
  add_foreign_key "signup_hints", "users", name: "signup_hints_user_id_fkey", on_delete: :cascade
  add_foreign_key "teacher_distributions", "lesson_package_purchases", name: "teacher_distributions_lesson_package_purchase_id_fkey"
  add_foreign_key "teacher_distributions", "lesson_sessions", name: "teacher_distributions_lesson_session_id_fkey"
  add_foreign_key "teacher_distributions", "retailers", name: "teacher_distributions_retailer_id_fkey"
  add_foreign_key "teacher_distributions", "schools", name: "teacher_distributions_school_id_fkey"
  add_foreign_key "teacher_distributions", "teacher_payments", name: "teacher_distributions_teacher_payment_id_fkey"
  add_foreign_key "teacher_distributions", "users", column: "teacher_id", name: "teacher_distributions_teacher_id_fkey"
  add_foreign_key "teacher_experiences", "teachers", name: "teacher_experiences_teacher_id_fkey", on_delete: :cascade
  add_foreign_key "teacher_intents", "teachers", name: "teacher_intents_teacher_id_fkey"
  add_foreign_key "teacher_intents", "users", name: "teacher_intents_user_id_fkey"
  add_foreign_key "teacher_payments", "charges", name: "teacher_payments_charge_id_fkey"
  add_foreign_key "teacher_payments", "retailers", name: "teacher_payments_retailer_id_fkey"
  add_foreign_key "teacher_payments", "schools", name: "teacher_payments_school_id_fkey"
  add_foreign_key "teacher_payments", "users", column: "teacher_id", name: "teacher_payments_teacher_id_fkey"
  add_foreign_key "teachers", "retailers", name: "teachers_retailer_id_fkey"
  add_foreign_key "teachers", "schools", name: "teachers_school_id_fkey"
  add_foreign_key "teachers_genres", "genres", name: "teachers_genres_genre_id_fkey", on_delete: :cascade
  add_foreign_key "teachers_genres", "teachers", name: "teachers_genres_teacher_id_fkey", on_delete: :cascade
  add_foreign_key "teachers_instruments", "instruments", name: "teachers_instruments_instrument_id_fkey", on_delete: :cascade
  add_foreign_key "teachers_instruments", "teachers", name: "teachers_instruments_teacher_id_fkey", on_delete: :cascade
  add_foreign_key "teachers_languages", "languages", name: "teachers_languages_language_id_fkey", on_delete: :cascade
  add_foreign_key "teachers_languages", "teachers", name: "teachers_languages_teacher_id_fkey", on_delete: :cascade
  add_foreign_key "teachers_subjects", "subjects", name: "teachers_subjects_subject_id_fkey", on_delete: :cascade
  add_foreign_key "teachers_subjects", "teachers", name: "teachers_subjects_teacher_id_fkey", on_delete: :cascade
  add_foreign_key "test_drive_package_choice_teachers", "test_drive_package_choices", name: "test_drive_package_choice_tea_test_drive_package_choice_id_fkey", on_delete: :cascade
  add_foreign_key "test_drive_package_choice_teachers", "users", column: "teacher_id", name: "test_drive_package_choice_teachers_teacher_id_fkey", on_delete: :cascade
  add_foreign_key "test_drive_package_choices", "test_drive_packages", name: "test_drive_package_choices_test_drive_package_id_fkey", on_delete: :cascade
  add_foreign_key "test_drive_package_choices", "users", name: "test_drive_package_choices_user_id_fkey", on_delete: :cascade
  add_foreign_key "test_drive_package_teachers", "test_drive_packages", name: "test_drive_package_teachers_test_drive_package_id_fkey", on_delete: :cascade
  add_foreign_key "test_drive_package_teachers", "users", name: "test_drive_package_teachers_user_id_fkey", on_delete: :cascade
  add_foreign_key "text_messages", "users", column: "source_user_id", name: "text_messages_source_user_id_fkey", on_delete: :cascade
  add_foreign_key "text_messages", "users", column: "target_user_id", name: "text_messages_target_user_id_fkey", on_delete: :cascade
  add_foreign_key "tracks", "connections", name: "connections_tracks_connection_id_fkey", on_delete: :cascade
  add_foreign_key "user_authorizations", "users", name: "user_authorizations_user_id_fkey", on_delete: :cascade
  add_foreign_key "user_blacklists", "users", name: "user_blacklists_user_id_fkey", on_delete: :cascade
  add_foreign_key "user_events", "users", name: "user_events_user_id_fkey", on_delete: :nullify
  add_foreign_key "user_whitelists", "users", name: "user_whitelists_user_id_fkey", on_delete: :cascade
  add_foreign_key "users", "affiliate_partners", column: "affiliate_referral_id", name: "users_affiliate_referral_id_fkey", on_delete: :nullify
  add_foreign_key "users", "icecast_server_groups", name: "users_icecast_server_group_id_fkey"
  add_foreign_key "users", "lesson_package_types", column: "lesson_package_needs_purchase_id", name: "users_lesson_package_needs_purchase_id_fkey", on_delete: :nullify
  add_foreign_key "users", "lesson_package_types", name: "users_lesson_package_type_id_fkey"
  add_foreign_key "users", "schools", name: "users_school_id_fkey"
  add_foreign_key "users", "teachers", name: "users_teacher_id_fkey", on_delete: :cascade
  add_foreign_key "users", "users", column: "onboarder_id", name: "users_onboarder_id_fkey", on_delete: :nullify
end
