Sha256: 562a8a5214961aab51a0290ae39d314651de7ec24f574b62a8f06da26a9f61f9

Contents?: true

Size: 626 Bytes

Versions: 13

Compression:

Stored size: 626 Bytes

Contents

require "sqlite3"

ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:")
ActiveRecord::Base.connection.tables.each do |table|
  ActiveRecord::Base.connection.drop_table(table, force: :cascade)
end
ActiveRecord::Schema.verbose = false
ActiveRecord::Base.logger = Logger.new($stdout)

ActiveRecord::Schema.define(version: 1) do
  create_table(:payments) do |t|
    t.belongs_to :user
    t.integer :amount
    t.timestamps
  end
  create_table(:users)
end

def fill_database
  10.times do
    user = User.create!
    10.times do
      Payment.create!(user: user, amount: rand(1000))
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
n1_loader-1.7.2 examples/context/setup_database.rb
n1_loader-1.7.1 examples/context/setup_database.rb
n1_loader-1.7.0 examples/context/setup_database.rb
n1_loader-1.6.6 examples/context/setup_database.rb
n1_loader-1.6.5 examples/context/setup_database.rb
n1_loader-1.6.4 examples/context/setup_database.rb
n1_loader-1.6.3 examples/context/setup_database.rb
n1_loader-1.6.2 examples/context/setup_database.rb
n1_loader-1.6.1 examples/context/setup_database.rb
n1_loader-1.6.0 examples/context/setup_database.rb
n1_loader-1.5.1 examples/context/setup_database.rb
n1_loader-1.5.0 examples/context/setup_database.rb
n1_loader-1.4.4 examples/context/setup_database.rb