Skip to content

Is there possible to write a one file runnable crystal to try reproduce possible bug in avram? #1881

Answered by jwoertink
zw963 asked this question in Q&A
Discussion options

You must be logged in to vote

Not tested, but you can try this

require "pg"
require "avram"

class AppDatabase < Avram::Database
end

AppDatabase.configure do |settings|
  settings.credentials = Avram::Credentials.new(database: "test_db", username: "postgres", hostname: "localhost")
end

Avram.configure do |settings|
  settings.database_to_migrate = AppDatabase
  settings.lazy_load_enabled = true
end

class CreateFoo::V20240420041990 < Avram::Migrator::Migration::V1
  def migrate
    create table_for(Foo), if_not_exists: true do
      primary_key id : Int64
      add is_211 : Bool, index: true, default: false
    end
  end

  def rollback
    drop table_for(Foo)
  end
end

Avram::Migrator::Runner.new.run_next_migration

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by zw963
Comment options

You must be logged in to vote
1 reply
@jwoertink
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants