diff --git a/db/schema.rb b/db/schema.rb index da0a466..7c1d057 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1,5 +1,3 @@ -# frozen_string_literal: true - # 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. @@ -12,104 +10,103 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.1].define(version: 20_240_826_053_051) do - create_table 'chats', force: :cascade do |t| - t.string 'name' - t.integer 'data_source_id', null: false - t.string 'slug' - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.string 'type' - t.index ['data_source_id'], name: 'index_chats_on_data_source_id' - t.index ['slug'], name: 'index_chats_on_slug', unique: true +ActiveRecord::Schema[7.1].define(version: 2024_08_26_053051) do + create_table "chats", force: :cascade do |t| + t.string "name" + t.integer "data_source_id", null: false + t.string "slug" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "type" + t.index ["data_source_id"], name: "index_chats_on_data_source_id" + t.index ["slug"], name: "index_chats_on_slug", unique: true end - create_table 'data_sources', force: :cascade do |t| - t.string 'adapter', null: false - t.string 'host' - t.integer 'port' - t.string 'database' - t.string 'username' - t.string 'password' - t.integer 'user_id', null: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.string 'name' - t.boolean 'connected', default: false, null: false - t.json 'schema', default: {}, null: false - t.string 'slug' - t.string 'autocomplete_schema' - t.index ['slug'], name: 'index_data_sources_on_slug', unique: true - t.index ['user_id'], name: 'index_data_sources_on_user_id' + create_table "data_sources", force: :cascade do |t| + t.string "adapter", null: false + t.string "host" + t.integer "port" + t.string "database" + t.string "username" + t.string "password" + t.integer "user_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "name" + t.boolean "connected", default: false, null: false + t.json "schema", default: {}, null: false + t.string "slug" + t.string "autocomplete_schema" + t.index ["slug"], name: "index_data_sources_on_slug", unique: true + t.index ["user_id"], name: "index_data_sources_on_user_id" end - create_table 'friendly_id_slugs', force: :cascade do |t| - t.string 'slug', null: false - t.integer 'sluggable_id', null: false - t.string 'sluggable_type', limit: 50 - t.string 'scope' - t.datetime 'created_at' - t.index %w[slug sluggable_type scope], name: 'index_friendly_id_slugs_on_slug_and_sluggable_type_and_scope', - unique: true - t.index %w[slug sluggable_type], name: 'index_friendly_id_slugs_on_slug_and_sluggable_type' - t.index %w[sluggable_type sluggable_id], name: 'index_friendly_id_slugs_on_sluggable_type_and_sluggable_id' + create_table "friendly_id_slugs", force: :cascade do |t| + t.string "slug", null: false + t.integer "sluggable_id", null: false + t.string "sluggable_type", limit: 50 + t.string "scope" + t.datetime "created_at" + t.index ["slug", "sluggable_type", "scope"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type_and_scope", unique: true + t.index ["slug", "sluggable_type"], name: "index_friendly_id_slugs_on_slug_and_sluggable_type" + t.index ["sluggable_type", "sluggable_id"], name: "index_friendly_id_slugs_on_sluggable_type_and_sluggable_id" end - create_table 'messages', force: :cascade do |t| - t.string 'role' - t.text 'content' - t.integer 'chat_id', null: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.text 'compiled_content' - t.index ['chat_id'], name: 'index_messages_on_chat_id' + create_table "messages", force: :cascade do |t| + t.string "role" + t.text "content" + t.integer "chat_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.text "compiled_content" + t.index ["chat_id"], name: "index_messages_on_chat_id" end - create_table 'queries', force: :cascade do |t| - t.string 'sql' - t.integer 'data_source_id', null: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.string 'name', null: false - t.string 'slug' - t.index ['data_source_id'], name: 'index_queries_on_data_source_id' + create_table "queries", force: :cascade do |t| + t.string "sql" + t.integer "data_source_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "name", null: false + t.string "slug" + t.index ["data_source_id"], name: "index_queries_on_data_source_id" end - create_table 'tables', force: :cascade do |t| - t.string 'name', null: false - t.integer 'data_source_id', null: false - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.string 'slug' - t.index %w[data_source_id name], name: 'index_tables_on_data_source_id_and_name', unique: true - t.index ['data_source_id'], name: 'index_tables_on_data_source_id' - t.index ['slug'], name: 'index_tables_on_slug', unique: true + create_table "tables", force: :cascade do |t| + t.string "name", null: false + t.integer "data_source_id", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "slug" + t.index ["data_source_id", "name"], name: "index_tables_on_data_source_id_and_name", unique: true + t.index ["data_source_id"], name: "index_tables_on_data_source_id" + t.index ["slug"], name: "index_tables_on_slug", unique: true end - create_table 'users', force: :cascade do |t| - t.string 'email', default: '', null: false - t.string 'encrypted_password', default: '', null: false - t.string 'reset_password_token' - t.datetime 'reset_password_sent_at' - t.datetime 'remember_created_at' - t.datetime 'created_at', null: false - t.datetime 'updated_at', null: false - t.string 'provider' - t.string 'uid' - t.string 'name' - t.string 'image' - t.string 'ai_url' - t.string 'ai_model' - t.string 'ai_api_key' - t.boolean 'darkmode', default: true - t.boolean 'admin' - t.index ['email'], name: 'index_users_on_email', unique: true - t.index ['reset_password_token'], name: 'index_users_on_reset_password_token', unique: true + create_table "users", force: :cascade do |t| + t.string "email", default: "", null: false + t.string "encrypted_password", default: "", null: false + t.string "reset_password_token" + t.datetime "reset_password_sent_at" + t.datetime "remember_created_at" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.string "provider" + t.string "uid" + t.string "name" + t.string "image" + t.string "ai_url" + t.string "ai_model" + t.string "ai_api_key" + t.boolean "darkmode", default: true + t.boolean "admin" + t.index ["email"], name: "index_users_on_email", unique: true + t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true end - add_foreign_key 'chats', 'data_sources' - add_foreign_key 'data_sources', 'users' - add_foreign_key 'messages', 'chats' - add_foreign_key 'queries', 'data_sources' - add_foreign_key 'tables', 'data_sources' + add_foreign_key "chats", "data_sources" + add_foreign_key "data_sources", "users" + add_foreign_key "messages", "chats" + add_foreign_key "queries", "data_sources" + add_foreign_key "tables", "data_sources" end diff --git a/docker-compose.yml b/docker-compose.yml index b759f2d..0da1031 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,8 +1,15 @@ +version: '3.8' + services: web: build: . - command: bash -c "rm -f tmp/pids/server.pid && bundle exec rails server -b 0.0.0.0 -p 3000" - entrypoint: ["./entrypoint.sh"] + command: bash -c " + export REDIS_URL=redis://redis:6379/1 && + export SECRET_KEY_BASE=$(bin/rails secret) && + rm -f tmp/pids/server.pid && + bundle exec rake assets:precompile && + bundle exec rails db:migrate && + bundle exec rails server -b 0.0.0.0 -p 3000" volumes: - .:/app ports: @@ -15,12 +22,17 @@ services: worker: build: . - command: bundle exec sidekiq - entrypoint: ["./sidekiq-entrypoint.sh"] + command: bash -c " + export REDIS_URL=redis://redis:6379/1 && + export SECRET_KEY_BASE=$(bin/rails secret) && + rm -f tmp/pids/server.pid && + bundle exec rails db:migrate && + bundle exec sidekiq" volumes: - .:/app environment: RAILS_ENV: production + REDIS_URL: redis://redis:6379/1 depends_on: - redis