Sha256: 83956b5be1752b60f8f5ce8b386a47a4c8a8bd6d5e2ccb1be69e08b57ab7bae1
Contents?: true
Size: 1.26 KB
Versions: 5
Compression:
Stored size: 1.26 KB
Contents
# frozen_string_literal: true ########################################### # Setup active record models ########################################## require "active_record" require "sqlite3" # Change the following to reflect your database settings ActiveRecord::Base.establish_connection( adapter: "sqlite3", database: ":memory:" ) # Don't show migration output when constructing fake db ActiveRecord::Migration.verbose = false ActiveRecord::Schema.define do create_table :authors, force: true do |t| t.string :name t.timestamps(null: false) end create_table :posts, force: true do |t| t.text :body t.string :title t.references :author t.json :data t.timestamps(null: false) end end class Author < ActiveRecord::Base has_one :profile has_many :posts end class Post < ActiveRecord::Base belongs_to :author end Post.destroy_all Author.destroy_all # Build out the data to serialize Post.transaction do ENV.fetch("ITEMS_COUNT", "2300").to_i.times do Post.create( body: "something about how password restrictions are evil, and less secure, and with the math to prove it.", title: "Your bank is does not know how to do security", author: Author.create(name: "Preston Sego"), data: { a: 1, b: 2, c: 3 } ) end end
Version data entries
5 entries across 5 versions & 1 rubygems