Class: Churned::Commands::DB::Create

Inherits:
Churned::Command show all
Defined in:
lib/churned/commands/db/create.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Churned::Command

#command, #cursor, #db, #editor, #exec_exist?, #generator, #pager, #platform, #prompt, #screen, #which

Constructor Details

#initialize(options) ⇒ Create

Returns a new instance of Create.



9
10
11
# File 'lib/churned/commands/db/create.rb', line 9

def initialize(options)
  @options = options
end

Class Method Details

.executeObject



13
14
15
# File 'lib/churned/commands/db/create.rb', line 13

def self.execute
  new({}).execute(input: $stdin, output: $stdout)
end

Instance Method Details

#execute(input: $stdin, output: $stdout) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/churned/commands/db/create.rb', line 17

def execute(input: $stdin, output: $stdout)
  generator.create_dir(".churned")

  ActiveRecord::Schema.define do
    create_table :commits, force: true do |t|
      t.string :sha
      t.string :author
      t.date :author_date
    end

    create_table :file_changes, force: true do |t|
      t.references :commit
      t.string :pathname
      t.integer :additions, default: 0
      t.integer :deletions, default: 0
    end
  end

end