tern 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. data/.gitignore +4 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.markdown +189 -0
  4. data/Rakefile +2 -0
  5. data/bin/tern +6 -0
  6. data/lib/tern.rb +207 -0
  7. data/lib/tern/app.rb +65 -0
  8. data/lib/tern/generators/change.sql +4 -0
  9. data/lib/tern/generators/new/alterations/.empty_directory +0 -0
  10. data/lib/tern/generators/new/alterations/001_create_people.sql.example +16 -0
  11. data/lib/tern/generators/new/config.yml.tt +15 -0
  12. data/lib/tern/generators/new/definitions/sequence.yml +18 -0
  13. data/lib/tern/generators/new/definitions/ultimate_answer.sql.example +7 -0
  14. data/spec/projects/alterations/alterations/001_create_people.sql +8 -0
  15. data/spec/projects/alterations/alterations/002_create_animals.sql +8 -0
  16. data/spec/projects/alterations/alterations/003_create_plants.sql +8 -0
  17. data/spec/projects/alterations/config.yml +15 -0
  18. data/spec/projects/alterations/definitions/sequence.yml +18 -0
  19. data/spec/projects/alterations/definitions/ultimate_answer.sql.example +7 -0
  20. data/spec/projects/definitions/alterations/001_create_people.sql.example +16 -0
  21. data/spec/projects/definitions/config.yml +15 -0
  22. data/spec/projects/definitions/definitions/sequence.yml +19 -0
  23. data/spec/projects/definitions/definitions/ultimate_answer.sql +7 -0
  24. data/spec/projects/dependencies_1/alterations/001_create_widgets.sql +9 -0
  25. data/spec/projects/dependencies_1/config.yml +15 -0
  26. data/spec/projects/dependencies_1/definitions/sequence.yml +19 -0
  27. data/spec/projects/dependencies_1/definitions/ultimate_answer.sql.example +7 -0
  28. data/spec/projects/dependencies_1/definitions/widgets_view.sql +5 -0
  29. data/spec/projects/dependencies_2/alterations/001_create_widgets.sql +9 -0
  30. data/spec/projects/dependencies_2/config.yml +15 -0
  31. data/spec/projects/dependencies_2/definitions/sequence.yml +18 -0
  32. data/spec/projects/dependencies_2/definitions/ultimate_answer.sql.example +7 -0
  33. data/spec/projects/duplicated_alteration/alterations/001_create_people.sql +8 -0
  34. data/spec/projects/duplicated_alteration/alterations/002_create_animals.sql +8 -0
  35. data/spec/projects/duplicated_alteration/alterations/002_create_plants.sql +8 -0
  36. data/spec/projects/duplicated_alteration/config.yml +15 -0
  37. data/spec/projects/duplicated_alteration/definitions/sequence.yml +18 -0
  38. data/spec/projects/duplicated_alteration/definitions/ultimate_answer.sql.example +7 -0
  39. data/spec/projects/irreversible_alterations/alterations/001_create_people.sql +8 -0
  40. data/spec/projects/irreversible_alterations/alterations/002_create_animals.sql +4 -0
  41. data/spec/projects/irreversible_alterations/alterations/003_create_plants.sql +8 -0
  42. data/spec/projects/irreversible_alterations/config.yml +15 -0
  43. data/spec/projects/irreversible_alterations/definitions/sequence.yml +18 -0
  44. data/spec/projects/irreversible_alterations/definitions/ultimate_answer.sql.example +7 -0
  45. data/spec/projects/missing_alteration/alterations/001_create_people.sql +8 -0
  46. data/spec/projects/missing_alteration/alterations/003_create_plants.sql +8 -0
  47. data/spec/projects/missing_alteration/config.yml +15 -0
  48. data/spec/projects/missing_alteration/definitions/sequence.yml +18 -0
  49. data/spec/projects/missing_alteration/definitions/ultimate_answer.sql.example +7 -0
  50. data/spec/projects/multiple_sequences/alterations/001_create_people.sql.example +16 -0
  51. data/spec/projects/multiple_sequences/config.yml +15 -0
  52. data/spec/projects/multiple_sequences/definitions/create_view_a.sql +5 -0
  53. data/spec/projects/multiple_sequences/definitions/create_view_b.sql +5 -0
  54. data/spec/projects/multiple_sequences/definitions/sequence.yml +21 -0
  55. data/spec/projects/multiple_sequences/definitions/ultimate_answer.sql.example +7 -0
  56. data/spec/projects/new/alterations/001_create_people.sql.example +16 -0
  57. data/spec/projects/new/config.yml +15 -0
  58. data/spec/projects/new/definitions/sequence.yml +18 -0
  59. data/spec/projects/new/definitions/ultimate_answer.sql.example +7 -0
  60. data/spec/projects/no_alterations/alterations/001_create_people.sql.example +16 -0
  61. data/spec/projects/no_alterations/config.yml +15 -0
  62. data/spec/projects/no_alterations/definitions/sequence.yml +18 -0
  63. data/spec/projects/no_alterations/definitions/ultimate_answer.sql.example +7 -0
  64. data/spec/tern_spec.rb +215 -0
  65. data/tern.gemspec +23 -0
  66. metadata +174 -0
@@ -0,0 +1,4 @@
1
+
2
+
3
+ ---- CREATE above / DROP below ----
4
+
@@ -0,0 +1,16 @@
1
+ Sequel.migration do
2
+ up do
3
+ run <<-END_SQL
4
+ CREATE TABLE people(
5
+ id serial PRIMARY KEY,
6
+ name varchar NOT NULL
7
+ );
8
+ END_SQL
9
+ end
10
+
11
+ down do
12
+ run <<-END_SQL
13
+ DROP TABLE people;
14
+ END_SQL
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ alterations:
2
+ table: tern_alterations
3
+ column: version
4
+ definitions:
5
+ table: tern_definitions
6
+ environments:
7
+ development:
8
+ adapter: postgres
9
+ database: <%= app_name %>_development
10
+ test:
11
+ adapter: postgres
12
+ database: <%= app_name %>_test
13
+ production:
14
+ adapter: postgres
15
+ database: <%= app_name %>_production
@@ -0,0 +1,18 @@
1
+ # Put the relative path to your definition files in the sequence they should run.
2
+ #
3
+ # Most definitions should go in the default list. These will be dropped and
4
+ # recreated every migration.
5
+ #
6
+ # Definitions that should not automatically be dropped and created can be put in
7
+ # different lists. This is useful for definitions that make take prohibitively
8
+ # to drop and create every migration such as check constraints.
9
+ #
10
+ # Run alternative sequences by specifying sequences in order to migrate command.
11
+ # Example: rake migrate sequences=expensive,default
12
+ #
13
+ # default:
14
+ # - ultimate_answer.sql
15
+ # expensive:
16
+ # - super_slow_check_constraint.sql
17
+
18
+ default: []
@@ -0,0 +1,7 @@
1
+ CREATE FUNCTION ultimate_answer() RETURNS integer AS $$
2
+ SELECT 42;
3
+ $$ LANGUAGE SQL;
4
+
5
+ ---- CREATE above / DROP below ----
6
+
7
+ DROP FUNCTION ultimate_answer();
@@ -0,0 +1,8 @@
1
+ CREATE TABLE people(
2
+ id serial PRIMARY KEY,
3
+ name varchar NOT NULL
4
+ );
5
+
6
+ ---- CREATE above / DROP below ----
7
+
8
+ DROP TABLE people;
@@ -0,0 +1,8 @@
1
+ CREATE TABLE animals(
2
+ id serial PRIMARY KEY,
3
+ name varchar NOT NULL
4
+ );
5
+
6
+ ---- CREATE above / DROP below ----
7
+
8
+ DROP TABLE animals;
@@ -0,0 +1,8 @@
1
+ CREATE TABLE plants(
2
+ id serial PRIMARY KEY,
3
+ name varchar NOT NULL
4
+ );
5
+
6
+ ---- CREATE above / DROP below ----
7
+
8
+ DROP TABLE plants;
@@ -0,0 +1,15 @@
1
+ alterations:
2
+ table: tern_alterations
3
+ column: version
4
+ definitions:
5
+ table: tern_definitions
6
+ environments:
7
+ development:
8
+ adapter: postgres
9
+ database: tern_test_development
10
+ test:
11
+ adapter: postgres
12
+ database: tern_test_test
13
+ production:
14
+ adapter: postgres
15
+ database: tern_test_production
@@ -0,0 +1,18 @@
1
+ # Put the relative path to your definition files in the sequence they should run.
2
+ #
3
+ # Most definitions should go in the default list. These will be dropped and
4
+ # recreated every migration.
5
+ #
6
+ # Definitions that should not automatically be dropped and created can be put in
7
+ # different lists. This is useful for definitions that make take prohibitively
8
+ # to drop and create every migration such as check constraints.
9
+ #
10
+ # Run alternative sequences by specifying sequences in order to migrate command.
11
+ # Example: rake migrate sequences=expensive,default
12
+ #
13
+ # default:
14
+ # - ultimate_answer.sql
15
+ # expensive:
16
+ # - super_slow_check_constraint.sql
17
+
18
+ default: []
@@ -0,0 +1,7 @@
1
+ CREATE FUNCTION ultimate_answer() RETURNS integer AS $$
2
+ SELECT 42;
3
+ $$ LANGUAGE SQL;
4
+
5
+ ---- CREATE above / DROP below ----
6
+
7
+ DROP FUNCTION ultimate_answer();
@@ -0,0 +1,16 @@
1
+ Sequel.migration do
2
+ up do
3
+ run <<-END_SQL
4
+ CREATE TABLE people(
5
+ id serial PRIMARY KEY,
6
+ name varchar NOT NULL
7
+ );
8
+ END_SQL
9
+ end
10
+
11
+ down do
12
+ run <<-END_SQL
13
+ DROP TABLE people;
14
+ END_SQL
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ alterations:
2
+ table: tern_alterations
3
+ column: version
4
+ definitions:
5
+ table: tern_definitions
6
+ environments:
7
+ development:
8
+ adapter: postgres
9
+ database: tern_test_development
10
+ test:
11
+ adapter: postgres
12
+ database: tern_test_test
13
+ production:
14
+ adapter: postgres
15
+ database: tern_test_production
@@ -0,0 +1,19 @@
1
+ # Put the relative path to your definition files in the sequence they should run.
2
+ #
3
+ # Most definitions should go in the default list. These will be dropped and
4
+ # recreated every migration.
5
+ #
6
+ # Definitions that should not automatically be dropped and created can be put in
7
+ # different lists. This is useful for definitions that make take prohibitively
8
+ # to drop and create every migration such as check constraints.
9
+ #
10
+ # Run alternative sequences by specifying sequences in order to migrate command.
11
+ # Example: rake migrate sequences=expensive,default
12
+ #
13
+ # default:
14
+ # - ultimate_answer.sql
15
+ # expensive:
16
+ # - super_slow_check_constraint.sql
17
+
18
+ default:
19
+ - ultimate_answer.sql
@@ -0,0 +1,7 @@
1
+ CREATE FUNCTION ultimate_answer() RETURNS integer AS $$
2
+ SELECT 42;
3
+ $$ LANGUAGE SQL;
4
+
5
+ ---- CREATE above / DROP below ----
6
+
7
+ DROP FUNCTION ultimate_answer();
@@ -0,0 +1,9 @@
1
+ CREATE TABLE widgets(
2
+ id serial PRIMARY KEY,
3
+ name varchar NOT NULL,
4
+ weight integer NOT NULL
5
+ );
6
+
7
+ ---- CREATE above / DROP below ----
8
+
9
+ DROP TABLE widgets;
@@ -0,0 +1,15 @@
1
+ alterations:
2
+ table: tern_alterations
3
+ column: version
4
+ definitions:
5
+ table: tern_definitions
6
+ environments:
7
+ development:
8
+ adapter: postgres
9
+ database: tern_test_development
10
+ test:
11
+ adapter: postgres
12
+ database: tern_test_test
13
+ production:
14
+ adapter: postgres
15
+ database: tern_test_production
@@ -0,0 +1,19 @@
1
+ # Put the relative path to your definition files in the sequence they should run.
2
+ #
3
+ # Most definitions should go in the default list. These will be dropped and
4
+ # recreated every migration.
5
+ #
6
+ # Definitions that should not automatically be dropped and created can be put in
7
+ # different lists. This is useful for definitions that make take prohibitively
8
+ # to drop and create every migration such as check constraints.
9
+ #
10
+ # Run alternative sequences by specifying sequences in order to migrate command.
11
+ # Example: rake migrate sequences=expensive,default
12
+ #
13
+ # default:
14
+ # - ultimate_answer.sql
15
+ # expensive:
16
+ # - super_slow_check_constraint.sql
17
+
18
+ default:
19
+ - widgets_view.sql
@@ -0,0 +1,7 @@
1
+ CREATE FUNCTION ultimate_answer() RETURNS integer AS $$
2
+ SELECT 42;
3
+ $$ LANGUAGE SQL;
4
+
5
+ ---- CREATE above / DROP below ----
6
+
7
+ DROP FUNCTION ultimate_answer();
@@ -0,0 +1,5 @@
1
+ CREATE VIEW widgets_view AS SELECT * FROM widgets;
2
+
3
+ ---- CREATE above / DROP below ----
4
+
5
+ DROP VIEW widgets_view;
@@ -0,0 +1,9 @@
1
+ CREATE TABLE widgets(
2
+ id serial PRIMARY KEY,
3
+ name varchar NOT NULL,
4
+ weight integer NOT NULL
5
+ );
6
+
7
+ ---- CREATE above / DROP below ----
8
+
9
+ DROP TABLE widgets;
@@ -0,0 +1,15 @@
1
+ alterations:
2
+ table: tern_alterations
3
+ column: version
4
+ definitions:
5
+ table: tern_definitions
6
+ environments:
7
+ development:
8
+ adapter: postgres
9
+ database: tern_test_development
10
+ test:
11
+ adapter: postgres
12
+ database: tern_test_test
13
+ production:
14
+ adapter: postgres
15
+ database: tern_test_production
@@ -0,0 +1,18 @@
1
+ # Put the relative path to your definition files in the sequence they should run.
2
+ #
3
+ # Most definitions should go in the default list. These will be dropped and
4
+ # recreated every migration.
5
+ #
6
+ # Definitions that should not automatically be dropped and created can be put in
7
+ # different lists. This is useful for definitions that make take prohibitively
8
+ # to drop and create every migration such as check constraints.
9
+ #
10
+ # Run alternative sequences by specifying sequences in order to migrate command.
11
+ # Example: rake migrate sequences=expensive,default
12
+ #
13
+ # default:
14
+ # - ultimate_answer.sql
15
+ # expensive:
16
+ # - super_slow_check_constraint.sql
17
+
18
+ default: []
@@ -0,0 +1,7 @@
1
+ CREATE FUNCTION ultimate_answer() RETURNS integer AS $$
2
+ SELECT 42;
3
+ $$ LANGUAGE SQL;
4
+
5
+ ---- CREATE above / DROP below ----
6
+
7
+ DROP FUNCTION ultimate_answer();
@@ -0,0 +1,8 @@
1
+ CREATE TABLE people(
2
+ id serial PRIMARY KEY,
3
+ name varchar NOT NULL
4
+ );
5
+
6
+ ---- CREATE above / DROP below ----
7
+
8
+ DROP TABLE people;
@@ -0,0 +1,8 @@
1
+ CREATE TABLE animals(
2
+ id serial PRIMARY KEY,
3
+ name varchar NOT NULL
4
+ );
5
+
6
+ ---- CREATE above / DROP below ----
7
+
8
+ DROP TABLE animals;
@@ -0,0 +1,8 @@
1
+ CREATE TABLE plants(
2
+ id serial PRIMARY KEY,
3
+ name varchar NOT NULL
4
+ );
5
+
6
+ ---- CREATE above / DROP below ----
7
+
8
+ DROP TABLE plants;
@@ -0,0 +1,15 @@
1
+ alterations:
2
+ table: tern_alterations
3
+ column: version
4
+ definitions:
5
+ table: tern_definitions
6
+ environments:
7
+ development:
8
+ adapter: postgres
9
+ database: tern_test_development
10
+ test:
11
+ adapter: postgres
12
+ database: tern_test_test
13
+ production:
14
+ adapter: postgres
15
+ database: tern_test_production
@@ -0,0 +1,18 @@
1
+ # Put the relative path to your definition files in the sequence they should run.
2
+ #
3
+ # Most definitions should go in the default list. These will be dropped and
4
+ # recreated every migration.
5
+ #
6
+ # Definitions that should not automatically be dropped and created can be put in
7
+ # different lists. This is useful for definitions that make take prohibitively
8
+ # to drop and create every migration such as check constraints.
9
+ #
10
+ # Run alternative sequences by specifying sequences in order to migrate command.
11
+ # Example: rake migrate sequences=expensive,default
12
+ #
13
+ # default:
14
+ # - ultimate_answer.sql
15
+ # expensive:
16
+ # - super_slow_check_constraint.sql
17
+
18
+ default: []
@@ -0,0 +1,7 @@
1
+ CREATE FUNCTION ultimate_answer() RETURNS integer AS $$
2
+ SELECT 42;
3
+ $$ LANGUAGE SQL;
4
+
5
+ ---- CREATE above / DROP below ----
6
+
7
+ DROP FUNCTION ultimate_answer();
@@ -0,0 +1,8 @@
1
+ CREATE TABLE people(
2
+ id serial PRIMARY KEY,
3
+ name varchar NOT NULL
4
+ );
5
+
6
+ ---- CREATE above / DROP below ----
7
+
8
+ DROP TABLE people;
@@ -0,0 +1,4 @@
1
+ CREATE TABLE animals(
2
+ id serial PRIMARY KEY,
3
+ name varchar NOT NULL
4
+ );
@@ -0,0 +1,8 @@
1
+ CREATE TABLE plants(
2
+ id serial PRIMARY KEY,
3
+ name varchar NOT NULL
4
+ );
5
+
6
+ ---- CREATE above / DROP below ----
7
+
8
+ DROP TABLE plants;
@@ -0,0 +1,15 @@
1
+ alterations:
2
+ table: tern_alterations
3
+ column: version
4
+ definitions:
5
+ table: tern_definitions
6
+ environments:
7
+ development:
8
+ adapter: postgres
9
+ database: tern_test_development
10
+ test:
11
+ adapter: postgres
12
+ database: tern_test_test
13
+ production:
14
+ adapter: postgres
15
+ database: tern_test_production