Sha256: a9dbaafc1a49682ceacee185c7c512eea939b8e8af3eb6afc18608131406d05d

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

#!/usr/bin/env ruby

$:.unshift(File.expand_path("../lib", __dir__))

# require "bundler/setup"
# Bundler.require :development

require "activerecord-cockroachdb-adapter"
# This allows playing with the rake task as well. Ex:
#
#     ActiveRecord::Tasks::DatabaseTasks.
#       structure_load(Post.connection_db_config, "awesome-file.sql")
require "active_record/connection_adapters/cockroachdb/database_tasks"

DB_NAME = "ar_crdb_console"

schema_kind = ENV.fetch("SCHEMA_KIND", ENV.fetch("SCHEMA", "default"))

system("cockroach sql --insecure --host=localhost:26257 --execute='drop database if exists #{DB_NAME}'",
  exception: true)
system("cockroach sql --insecure --host=localhost:26257 --execute='create database #{DB_NAME}'",
  exception: true)

ActiveRecord::Base.establish_connection(
  #Alternative version:  "cockroachdb://root@localhost:26257/#{DB_NAME}"
  adapter: "cockroachdb",
  host: "localhost",
  port: 26257,
  user: "root",
  database: DB_NAME
)

load "#{__dir__}/console_schemas/#{schema_kind}.rb"

require "irb"
IRB.start(__FILE__)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
activerecord-cockroachdb-adapter-8.0.1 bin/console
activerecord-cockroachdb-adapter-8.0.0 bin/console