my_enginery 0.2.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/.travis.yml +9 -0
- data/CHANGELOG.md +14 -0
- data/Gemfile +12 -0
- data/LICENSE +19 -0
- data/README.md +957 -0
- data/Rakefile +48 -0
- data/app/base/.pryrc +1 -0
- data/app/base/Gemfile +25 -0
- data/app/base/Rakefile +4 -0
- data/app/base/app.rb +8 -0
- data/app/base/base/boot.rb +45 -0
- data/app/base/base/config.rb +127 -0
- data/app/base/base/controllers/rear-controllers/.gitkeep +0 -0
- data/app/base/base/database.rb +3 -0
- data/app/base/base/helpers/application_helpers.rb +3 -0
- data/app/base/base/migrations/.gitkeep +0 -0
- data/app/base/base/models/.gitkeep +0 -0
- data/app/base/base/specs/.gitkeep +0 -0
- data/app/base/base/views/.gitkeep +0 -0
- data/app/base/config.ru +4 -0
- data/app/base/config/config.yml +17 -0
- data/app/base/public/assets/Enginery.png +0 -0
- data/app/base/public/assets/Espresso.png +0 -0
- data/app/base/public/assets/application.css +13 -0
- data/app/base/public/assets/application.js +2 -0
- data/app/base/public/assets/bootstrap/css/bootstrap-responsive.min.css +9 -0
- data/app/base/public/assets/bootstrap/css/bootstrap.min.css +9 -0
- data/app/base/public/assets/bootstrap/img/glyphicons-halflings-white.png +0 -0
- data/app/base/public/assets/bootstrap/img/glyphicons-halflings.png +0 -0
- data/app/base/public/assets/bootstrap/js/bootstrap.min.js +6 -0
- data/app/base/public/assets/jquery.js +6 -0
- data/app/base/var/db/.gitkeep +0 -0
- data/app/base/var/log/.gitkeep +0 -0
- data/app/base/var/pid/.gitkeep +0 -0
- data/app/database/ActiveRecord.rb +11 -0
- data/app/database/DataMapper.rb +11 -0
- data/app/database/Sequel.rb +11 -0
- data/app/database/mysql.yml +24 -0
- data/app/database/postgres.yml +24 -0
- data/app/database/sqlite.yml +24 -0
- data/app/gemfiles/ActiveRecord.rb +1 -0
- data/app/gemfiles/BlueCloth.rb +1 -0
- data/app/gemfiles/DataMapper.rb +1 -0
- data/app/gemfiles/FastCGI.rb +1 -0
- data/app/gemfiles/Puma.rb +1 -0
- data/app/gemfiles/RDiscount.rb +1 -0
- data/app/gemfiles/RDoc.rb +1 -0
- data/app/gemfiles/RedCloth.rb +1 -0
- data/app/gemfiles/WEBrick.rb +1 -0
- data/app/gemfiles/WikiCloth.rb +1 -0
- data/app/gemfiles/mysql/ActiveRecord.rb +1 -0
- data/app/gemfiles/mysql/DataMapper.rb +1 -0
- data/app/gemfiles/mysql/Sequel.rb +1 -0
- data/app/gemfiles/postgres/ActiveRecord.rb +1 -0
- data/app/gemfiles/postgres/DataMapper.rb +1 -0
- data/app/gemfiles/postgres/Sequel.rb +1 -0
- data/app/gemfiles/sqlite/ActiveRecord.rb +1 -0
- data/app/gemfiles/sqlite/DataMapper.rb +1 -0
- data/app/gemfiles/sqlite/Sequel.rb +1 -0
- data/app/layouts/ERB/layout.erb +56 -0
- data/app/layouts/Erubis/layout.erb +56 -0
- data/app/layouts/Haml/layout.haml +38 -0
- data/app/layouts/Slim/layout.slim +38 -0
- data/app/migrations/ActiveRecord.erb +51 -0
- data/app/migrations/DataMapper.erb +61 -0
- data/app/migrations/Sequel.erb +54 -0
- data/app/migrations/tracking_table/ActiveRecord.rb +19 -0
- data/app/migrations/tracking_table/DataMapper.rb +26 -0
- data/app/migrations/tracking_table/Sequel.rb +18 -0
- data/app/rakefiles/ActiveRecord.rb +0 -0
- data/app/rakefiles/DataMapper.rb +1 -0
- data/app/rakefiles/Sequel.rb +0 -0
- data/app/rakefiles/Specular.rb +1 -0
- data/app/specfiles/Specular.erb +7 -0
- data/bin/my_enginery +235 -0
- data/lib/enginery.rb +23 -0
- data/lib/enginery/cli.rb +44 -0
- data/lib/enginery/configurator.rb +139 -0
- data/lib/enginery/delete.rb +116 -0
- data/lib/enginery/enginery.rb +41 -0
- data/lib/enginery/generator.rb +325 -0
- data/lib/enginery/helpers/app.rb +83 -0
- data/lib/enginery/helpers/generic.rb +145 -0
- data/lib/enginery/helpers/input.rb +123 -0
- data/lib/enginery/helpers/orm.rb +86 -0
- data/lib/enginery/helpers/validations.rb +101 -0
- data/lib/enginery/migrator.rb +371 -0
- data/lib/enginery/rake-tasks/data_mapper.rb +49 -0
- data/lib/enginery/rake-tasks/specular.rb +41 -0
- data/lib/enginery/registry.rb +101 -0
- data/lib/enginery/usage.rb +66 -0
- data/lib/enginery/version.rb +7 -0
- data/logo.png +0 -0
- data/my_enginery.gemspec +37 -0
- data/test/delete/test__admin.rb +49 -0
- data/test/delete/test__controller.rb +37 -0
- data/test/delete/test__helper.rb +49 -0
- data/test/delete/test__migration.rb +27 -0
- data/test/delete/test__model.rb +35 -0
- data/test/delete/test__route.rb +35 -0
- data/test/delete/test__spec.rb +59 -0
- data/test/delete/test__view.rb +51 -0
- data/test/generator/test__admin.rb +39 -0
- data/test/generator/test__controller.rb +123 -0
- data/test/generator/test__helper.rb +56 -0
- data/test/generator/test__model.rb +206 -0
- data/test/generator/test__project.rb +81 -0
- data/test/generator/test__route.rb +110 -0
- data/test/generator/test__spec.rb +56 -0
- data/test/generator/test__view.rb +85 -0
- data/test/migrator/test__auto_generation.rb +41 -0
- data/test/migrator/test__manual_generation.rb +59 -0
- data/test/migrator/test__migrations.rb +139 -0
- data/test/sandbox/.gitkeep +0 -0
- data/test/setup.rb +29 -0
- data/test/support/spec_helpers.rb +151 -0
- metadata +392 -0
@@ -0,0 +1,24 @@
|
|
1
|
+
---
|
2
|
+
development:
|
3
|
+
type: postgres
|
4
|
+
host: localhost
|
5
|
+
port:
|
6
|
+
name:
|
7
|
+
user:
|
8
|
+
pass:
|
9
|
+
|
10
|
+
test:
|
11
|
+
type: postgres
|
12
|
+
host: localhost
|
13
|
+
port:
|
14
|
+
name:
|
15
|
+
user:
|
16
|
+
pass:
|
17
|
+
|
18
|
+
production:
|
19
|
+
type: postgres
|
20
|
+
host: localhost
|
21
|
+
port:
|
22
|
+
name:
|
23
|
+
user:
|
24
|
+
pass:
|
@@ -0,0 +1,24 @@
|
|
1
|
+
---
|
2
|
+
development:
|
3
|
+
type: sqlite3
|
4
|
+
host:
|
5
|
+
port:
|
6
|
+
name: var/db/development.db
|
7
|
+
user:
|
8
|
+
pass:
|
9
|
+
|
10
|
+
test:
|
11
|
+
type: sqlite3
|
12
|
+
host:
|
13
|
+
port:
|
14
|
+
name: var/db/test.db
|
15
|
+
user:
|
16
|
+
pass:
|
17
|
+
|
18
|
+
production:
|
19
|
+
type:
|
20
|
+
host:
|
21
|
+
port:
|
22
|
+
name:
|
23
|
+
user:
|
24
|
+
pass:
|
@@ -0,0 +1 @@
|
|
1
|
+
gem 'activerecord', require: 'active_record'
|
@@ -0,0 +1 @@
|
|
1
|
+
gem 'bluecloth'
|
@@ -0,0 +1 @@
|
|
1
|
+
gem 'data_mapper'
|
@@ -0,0 +1 @@
|
|
1
|
+
gem 'fcgi'
|
@@ -0,0 +1 @@
|
|
1
|
+
gem 'puma', require: ['puma', 'rack/handler/puma']
|
@@ -0,0 +1 @@
|
|
1
|
+
gem 'rdiscount'
|
@@ -0,0 +1 @@
|
|
1
|
+
gem 'rdoc'
|
@@ -0,0 +1 @@
|
|
1
|
+
gem 'redcloth'
|
@@ -0,0 +1 @@
|
|
1
|
+
# keep this file otherwise "gem 'webrick'" will be added to Gemfile
|
@@ -0,0 +1 @@
|
|
1
|
+
gem 'wikicloth'
|
@@ -0,0 +1 @@
|
|
1
|
+
gem 'mysql'
|
@@ -0,0 +1 @@
|
|
1
|
+
gem 'dm-mysql-adapter'
|
@@ -0,0 +1 @@
|
|
1
|
+
gem 'mysql'
|
@@ -0,0 +1 @@
|
|
1
|
+
gem 'pg'
|
@@ -0,0 +1 @@
|
|
1
|
+
gem 'dm-postgres-adapter'
|
@@ -0,0 +1 @@
|
|
1
|
+
gem 'pg'
|
@@ -0,0 +1 @@
|
|
1
|
+
gem 'sqlite3'
|
@@ -0,0 +1 @@
|
|
1
|
+
gem 'dm-sqlite-adapter'
|
@@ -0,0 +1 @@
|
|
1
|
+
gem 'sqlite3'
|
@@ -0,0 +1,56 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title></title>
|
5
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
|
6
|
+
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
|
7
|
+
<%= js_tag 'application' %>
|
8
|
+
<%= css_tag 'application' %>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<div class="hero-unit text-center">
|
12
|
+
<h1 class="espresso-heading">
|
13
|
+
Welcome to Espresso World
|
14
|
+
</h1>
|
15
|
+
<h2>
|
16
|
+
This is your Brand New Application
|
17
|
+
</h2>
|
18
|
+
<p class="lead text-info">
|
19
|
+
Edit "<%= __FILE__.sub(Cfg.root_path, '') %>" to get rid of this banner
|
20
|
+
</p>
|
21
|
+
</div>
|
22
|
+
<div class="container">
|
23
|
+
<div class="row">
|
24
|
+
<div class="span4">
|
25
|
+
<%= png_tag 'Espresso' %>
|
26
|
+
</div>
|
27
|
+
<div class="span8">
|
28
|
+
<h4 class="espresso-heading">
|
29
|
+
<br />
|
30
|
+
Running on
|
31
|
+
<a href="https://github.com/espresso/espresso">Espresso</a>
|
32
|
+
<span class="muted"> <%= EVersion::FULL %></span>
|
33
|
+
</h4>
|
34
|
+
<p class="lead">
|
35
|
+
<a href="http://espresso.github.io">espresso.github.io</a>
|
36
|
+
</p>
|
37
|
+
</div>
|
38
|
+
</div>
|
39
|
+
<div class="row">
|
40
|
+
<hr />
|
41
|
+
<div class="span8">
|
42
|
+
<h4 class="espresso-heading">
|
43
|
+
Built with care by <a href="https://github.com/espresso/enginery">Enginery</a>
|
44
|
+
</h4>
|
45
|
+
<p class="lead">
|
46
|
+
<a href="https://github.com/espresso/enginery">github.com/espresso/enginery</a>
|
47
|
+
</p>
|
48
|
+
</div>
|
49
|
+
<div class="span4">
|
50
|
+
<%= png_tag 'Enginery' %>
|
51
|
+
</div>
|
52
|
+
</div>
|
53
|
+
<%= yield %>
|
54
|
+
</div>
|
55
|
+
</body>
|
56
|
+
</html>
|
@@ -0,0 +1,56 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title></title>
|
5
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
|
6
|
+
<meta content="width=device-width, initial-scale=1.0" name="viewport" />
|
7
|
+
<%= js_tag 'application' %>
|
8
|
+
<%= css_tag 'application' %>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<div class="hero-unit text-center">
|
12
|
+
<h1 class="espresso-heading">
|
13
|
+
Welcome to Espresso World
|
14
|
+
</h1>
|
15
|
+
<h2>
|
16
|
+
This is your Brand New Application
|
17
|
+
</h2>
|
18
|
+
<p class="lead text-info">
|
19
|
+
Edit "<%= __FILE__.sub(Cfg.root_path, '') %>" to get rid of this banner
|
20
|
+
</p>
|
21
|
+
</div>
|
22
|
+
<div class="container">
|
23
|
+
<div class="row">
|
24
|
+
<div class="span4">
|
25
|
+
<%= png_tag 'Espresso' %>
|
26
|
+
</div>
|
27
|
+
<div class="span8">
|
28
|
+
<h4 class="espresso-heading">
|
29
|
+
<br />
|
30
|
+
Running on
|
31
|
+
<a href="https://github.com/espresso/espresso">Espresso</a>
|
32
|
+
<span class="muted"> <%= EVersion::FULL %></span>
|
33
|
+
</h4>
|
34
|
+
<p class="lead">
|
35
|
+
<a href="http://espresso.github.io">espresso.github.io</a>
|
36
|
+
</p>
|
37
|
+
</div>
|
38
|
+
</div>
|
39
|
+
<div class="row">
|
40
|
+
<hr />
|
41
|
+
<div class="span8">
|
42
|
+
<h4 class="espresso-heading">
|
43
|
+
Built with care by <a href="https://github.com/espresso/enginery">Enginery</a>
|
44
|
+
</h4>
|
45
|
+
<p class="lead">
|
46
|
+
<a href="https://github.com/espresso/enginery">github.com/espresso/enginery</a>
|
47
|
+
</p>
|
48
|
+
</div>
|
49
|
+
<div class="span4">
|
50
|
+
<%= png_tag 'Enginery' %>
|
51
|
+
</div>
|
52
|
+
</div>
|
53
|
+
<%= yield %>
|
54
|
+
</div>
|
55
|
+
</body>
|
56
|
+
</html>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
!!! 5
|
2
|
+
%html
|
3
|
+
%head
|
4
|
+
%title
|
5
|
+
%meta{'http-equiv' => "Content-Type", content: "text/html; charset=UTF-8"}
|
6
|
+
%meta{name: "viewport", content: "width=device-width, initial-scale=1.0"}
|
7
|
+
= js_tag 'application'
|
8
|
+
= css_tag 'application'
|
9
|
+
|
10
|
+
%body
|
11
|
+
%div.hero-unit.text-center
|
12
|
+
%h1.espresso-heading Welcome to Espresso World
|
13
|
+
%h2 This is your Brand New Application
|
14
|
+
%p.lead.text-info Edit "#{__FILE__.sub(Cfg.root_path, '')}" to get rid of this banner
|
15
|
+
%div.container
|
16
|
+
%div.row
|
17
|
+
%div.span4
|
18
|
+
= png_tag 'Espresso'
|
19
|
+
%div.span8
|
20
|
+
%h4.espresso-heading
|
21
|
+
%br
|
22
|
+
Running on
|
23
|
+
%a{href: "https://github.com/espresso/espresso"} Espresso
|
24
|
+
%span.muted #{EVersion::FULL}
|
25
|
+
%p.lead
|
26
|
+
%a{href: "http://espresso.github.io"} espresso.github.io
|
27
|
+
%div.row
|
28
|
+
%hr
|
29
|
+
%div.span8
|
30
|
+
%h4.espresso-heading
|
31
|
+
Built with care by
|
32
|
+
%a{href: "https://github.com/espresso/enginery"} Enginery
|
33
|
+
%p.lead
|
34
|
+
%a{href: "https://github.com/espresso/enginery"} github.com/espresso/enginery
|
35
|
+
%div.span4
|
36
|
+
= png_tag 'Enginery'
|
37
|
+
|
38
|
+
= yield
|
@@ -0,0 +1,38 @@
|
|
1
|
+
doctype html
|
2
|
+
html
|
3
|
+
head
|
4
|
+
title
|
5
|
+
meta http-equiv="Content-Type" content="text/html; charset=UTF-8"
|
6
|
+
meta name="viewport" content="width=device-width, initial-scale=1.0"
|
7
|
+
== js_tag 'application'
|
8
|
+
== css_tag 'application'
|
9
|
+
|
10
|
+
body
|
11
|
+
.hero-unit.text-center
|
12
|
+
h1.espresso-heading Welcome to Espresso World
|
13
|
+
h2 This is your Brand New Application
|
14
|
+
p.lead.text-info Edit "#{__FILE__.sub(Cfg.root_path, '')}" to get rid of this banner
|
15
|
+
.container
|
16
|
+
.row
|
17
|
+
.span4
|
18
|
+
== png_tag 'Espresso'
|
19
|
+
.span8
|
20
|
+
h4.espresso-heading
|
21
|
+
br
|
22
|
+
| Running on
|
23
|
+
a href="https://github.com/espresso/espresso" Espresso
|
24
|
+
span.muted #{EVersion::FULL}
|
25
|
+
p.lead
|
26
|
+
a href="http://espresso.github.io" espresso.github.io
|
27
|
+
.row
|
28
|
+
hr
|
29
|
+
.span8
|
30
|
+
h4.espresso-heading
|
31
|
+
| Built with care by
|
32
|
+
a href="https://github.com/espresso/enginery" Enginery
|
33
|
+
p.lead
|
34
|
+
a href="https://github.com/espresso/enginery" github.com/espresso/enginery
|
35
|
+
.span4
|
36
|
+
== png_tag 'Enginery'
|
37
|
+
|
38
|
+
== yield
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Enginery
|
2
|
+
class Migrator
|
3
|
+
class MigratorInstance < ActiveRecord::Migration
|
4
|
+
def up
|
5
|
+
<?rb if @create_table ?>
|
6
|
+
create_table :#{ @create_table } do |t|
|
7
|
+
<?rb @create_columns.each do |(n,t)|?>
|
8
|
+
t.#{ t } :#{ n }
|
9
|
+
<?rb end ?>
|
10
|
+
end
|
11
|
+
<?rb elsif @update_table && @create_columns.any? ?>
|
12
|
+
change_table :#{ @update_table } do |t|
|
13
|
+
<?rb @create_columns.each do |(n,t)|?>
|
14
|
+
t.#{ t } :#{ n }
|
15
|
+
<?rb end ?>
|
16
|
+
end
|
17
|
+
<?rb end ?>
|
18
|
+
|
19
|
+
<?rb @update_columns.each do |(n,t)|?>
|
20
|
+
change_column :#{ @update_table }, :#{ n }, :#{ t }
|
21
|
+
<?rb end ?>
|
22
|
+
|
23
|
+
<?rb @rename_columns.each do |(n,nn)|?>
|
24
|
+
rename_column :#{ @update_table }, :#{ n }, :#{ nn }
|
25
|
+
<?rb end ?>
|
26
|
+
end
|
27
|
+
|
28
|
+
def down
|
29
|
+
<?rb if @create_table ?>
|
30
|
+
drop_table :#{ @create_table }
|
31
|
+
<?rb elsif @update_table ?>
|
32
|
+
|
33
|
+
<?rb @create_columns.each do |(n,t)|?>
|
34
|
+
remove_column :#{ @update_table }, :#{ n }
|
35
|
+
<?rb end ?>
|
36
|
+
|
37
|
+
<?rb if (update_columns = @update_columns.select {|n,t,ct| ct}).any?
|
38
|
+
update_columns.each do |(n,t,ct)|?>
|
39
|
+
change_column :#{ @update_table }, :#{ n }, :#{ ct }
|
40
|
+
<?rb end
|
41
|
+
end ?>
|
42
|
+
|
43
|
+
<?rb @rename_columns.each do |(n,nn)|?>
|
44
|
+
rename_column :#{ @update_table }, :#{ nn }, :#{ n }
|
45
|
+
<?rb end ?>
|
46
|
+
|
47
|
+
<?rb end ?>
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'dm-migrations'
|
2
|
+
module Enginery
|
3
|
+
class Migrator
|
4
|
+
MigratorInstance = DataMapper::Migration.new #{ @step }, "#{ @name }" do
|
5
|
+
up do
|
6
|
+
<?rb if @create_table ?>
|
7
|
+
create_table :#{ @create_table } do
|
8
|
+
column :id, Integer, serial: true
|
9
|
+
<?rb @create_columns.each do |(n,t)| ?>
|
10
|
+
column :#{ n }, #{ t }
|
11
|
+
<?rb end ?>
|
12
|
+
end
|
13
|
+
|
14
|
+
<?rb elsif @update_table ?>
|
15
|
+
modify_table :#{ @update_table } do
|
16
|
+
|
17
|
+
<?rb @create_columns.each do |(n,t)| ?>
|
18
|
+
add_column :#{ n }, #{ t }
|
19
|
+
<?rb end ?>
|
20
|
+
|
21
|
+
<?rb @update_columns.each do |(n,t)| ?>
|
22
|
+
change_column :#{ n }, #{ t }
|
23
|
+
<?rb end ?>
|
24
|
+
|
25
|
+
<?rb @rename_columns.each do |(n,nn)| ?>
|
26
|
+
rename_column :#{ n }, :#{ nn }
|
27
|
+
<?rb end ?>
|
28
|
+
end
|
29
|
+
<?rb end ?>
|
30
|
+
end
|
31
|
+
|
32
|
+
down do
|
33
|
+
<?rb if @create_table ?>
|
34
|
+
drop_table :#{ @create_table }
|
35
|
+
<?rb elsif @update_table ?>
|
36
|
+
modify_table :#{ @update_table } do
|
37
|
+
|
38
|
+
<?rb @create_columns.each do |(n,t)| ?>
|
39
|
+
drop_column :#{ n }
|
40
|
+
<?rb end ?>
|
41
|
+
|
42
|
+
<?rb if (update_columns = @update_columns.select {|n,t,ct| ct}).any?
|
43
|
+
update_columns.each do |(n,t,ct)| ?>
|
44
|
+
change_column :#{ n }, #{ ct }
|
45
|
+
<?rb end
|
46
|
+
end ?>
|
47
|
+
|
48
|
+
<?rb @rename_columns.each do |(n,nn)| ?>
|
49
|
+
rename_column :#{ nn }, :#{ n }
|
50
|
+
<?rb end ?>
|
51
|
+
|
52
|
+
end
|
53
|
+
<?rb end ?>
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# *** do not remove this ***
|
58
|
+
MigratorContext = #{@context}
|
59
|
+
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
Sequel.extension :migration
|
2
|
+
module Enginery
|
3
|
+
class Migrator
|
4
|
+
MigratorInstance = Sequel.migration do
|
5
|
+
up do
|
6
|
+
<?rb if @create_table ?>
|
7
|
+
create_table :#{ @create_table } do
|
8
|
+
primary_key :id
|
9
|
+
<?rb @create_columns.each do |(n,t)| ?>
|
10
|
+
column :#{ n }, #{ t }
|
11
|
+
<?rb end ?>
|
12
|
+
end
|
13
|
+
<?rb elsif @update_table && (@create_columns.any? || @update_columns.any?) ?>
|
14
|
+
alter_table :#{ @update_table } do
|
15
|
+
<?rb @create_columns.each do |(n,t)| ?>
|
16
|
+
add_column :#{ n }, #{ t }
|
17
|
+
<?rb end ?>
|
18
|
+
<?rb @update_columns.each do |(n,t)| ?>
|
19
|
+
set_column_type :#{ n }, #{ t }
|
20
|
+
<?rb end ?>
|
21
|
+
end
|
22
|
+
<?rb end ?>
|
23
|
+
|
24
|
+
<?rb @rename_columns.each do |(n,nn)| ?>
|
25
|
+
rename_column :#{ @update_table }, :#{ n }, :#{ nn }
|
26
|
+
<?rb end ?>
|
27
|
+
end
|
28
|
+
|
29
|
+
down do
|
30
|
+
<?rb if @create_table ?>
|
31
|
+
drop_table :#{ @create_table }
|
32
|
+
<?rb elsif @update_table && (@create_columns.any? || @update_columns.any?) ?>
|
33
|
+
alter_table :#{ @update_table } do
|
34
|
+
<?rb @create_columns.each do |(n,t)| ?>
|
35
|
+
drop_column :#{ n }
|
36
|
+
<?rb end ?>
|
37
|
+
<?rb if (update_columns = @update_columns.select {|n,t,ct| ct}).any?
|
38
|
+
update_columns.each do |(n,t,ct)| ?>
|
39
|
+
set_column_type :#{ n }, #{ ct }
|
40
|
+
<?rb end
|
41
|
+
end ?>
|
42
|
+
end
|
43
|
+
<?rb end ?>
|
44
|
+
|
45
|
+
<?rb @rename_columns.each do |(n,nn)| ?>
|
46
|
+
rename_column :#{ @update_table }, :#{ nn }, :#{ n }
|
47
|
+
<?rb end ?>
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# *** do not remove this ***
|
52
|
+
MigratorContext = #{@context}
|
53
|
+
end
|
54
|
+
end
|