Class: CreatePosts

Inherits:
Object
  • Object
show all
Defined in:
lib/db/create_posts.rb

Instance Method Summary collapse

Instance Method Details

#callObject



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/db/create_posts.rb', line 2

def call
  return if Rubee::SequelObject::DB.tables.include?(:posts)

  Rubee::SequelObject::DB.create_table(:posts) do
    primary_key(:id)
    foreign_key(:user_id, :users)
    foreign_key(:comment_id, :comments)
    # timestamps
    datetime(:created)
    datetime(:updated)
  end

  Post.create(user_id: User.all.first.id, comment_id: Comment.all.first.id)
  Post.create(user_id: User.all.last.id, comment_id: Comment.all.last.id)
end