Skip to content

Commit

Permalink
migration setup update
Browse files Browse the repository at this point in the history
  • Loading branch information
Thiru Njuguna committed Oct 28, 2018
1 parent 2afcab5 commit e7d7286
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
14 changes: 13 additions & 1 deletion lib/natra/generators/app/app_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,22 @@ def create_empty_directories

empty_directory File.join(@app_path, 'db/migrate')

create_file File.join(@app_path, "lib", ".gitkeep")
create_file File.join(@app_path, "lib", ".keep")
template "config/environment.rb", File.join(@app_path, "config/environment.rb")
end

def create_seeds_file
create_file File.join(@app_path, "db", "seeds.rb")
end

def initialize_db
copy_file('bin/setup', File.join(@app_path, "bin/setup"))
end

def uuid_setup
template 'db/migrate/add_extensions.rb', File.join(@app_path,"db/migrate/#{Time.now.strftime('%Y%m%d')}0000_add_extensions.rb")
end

def create_public_directory
template "public/favicon.ico", File.join(@app_path, "public/favicon.ico")
end
Expand Down
1 change: 0 additions & 1 deletion lib/natra/generators/app/templates/Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ gem 'sinatra-activerecord', :require => 'sinatra/activerecord'
gem 'rake'
gem 'rack-timeout'
gem 'require_all'
gem 'sqlite3'
gem 'thin'
gem 'shotgun'
gem 'scout_apm'
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class AddExtensions < ActiveRecord::Migration
def change
enable_extension 'hstore'
enable_extension 'uuid-ossp'
enable_extension 'pgcrypto'
end
end
2 changes: 1 addition & 1 deletion lib/natra/generators/model/migration.rb.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class <%= migration_class_name %> < ActiveRecord::Migration
def change
create_table :<%= table_name %> do |t|
create_table :<%= table_name %> ,id: :uuid do |t|
<% attributes.each do |attribute| -%>
t.<%= attribute[:type] %> :<%= attribute[:name] %>
<% end %>
Expand Down

0 comments on commit e7d7286

Please sign in to comment.