prick 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -5
  3. data/Gemfile +4 -1
  4. data/TODO +3 -0
  5. data/doc/prick.txt +114 -0
  6. data/exe/prick +224 -370
  7. data/lib/ext/fileutils.rb +11 -0
  8. data/lib/ext/forward_method.rb +18 -0
  9. data/lib/ext/shortest_path.rb +44 -0
  10. data/lib/prick.rb +17 -9
  11. data/lib/prick/branch.rb +254 -0
  12. data/lib/prick/builder.rb +141 -0
  13. data/lib/prick/command.rb +19 -11
  14. data/lib/prick/constants.rb +42 -20
  15. data/lib/prick/database.rb +5 -3
  16. data/lib/prick/diff.rb +47 -0
  17. data/lib/prick/exceptions.rb +15 -3
  18. data/lib/prick/git.rb +46 -21
  19. data/lib/prick/migration.rb +165 -185
  20. data/lib/prick/program.rb +238 -0
  21. data/lib/prick/project.rb +266 -358
  22. data/lib/prick/rdbms.rb +2 -2
  23. data/lib/prick/schema.rb +19 -88
  24. data/lib/prick/share.rb +64 -0
  25. data/lib/prick/state.rb +137 -0
  26. data/lib/prick/version.rb +34 -14
  27. data/libexec/strip-comments +33 -0
  28. data/make_releases +48 -345
  29. data/make_schema +10 -0
  30. data/prick.gemspec +11 -22
  31. data/share/feature_migration/diff.sql +2 -0
  32. data/share/feature_migration/migrate.sql +2 -0
  33. data/share/release_migration/diff.sql +3 -0
  34. data/share/release_migration/features.yml +6 -0
  35. data/share/release_migration/migrate.sql +5 -0
  36. data/share/release_migration/migrate.yml +5 -0
  37. data/share/schema/build.yml +14 -0
  38. data/share/schema/schema.sql +5 -0
  39. data/share/schemas/build.yml +3 -0
  40. data/share/schemas/prick/build.yml +14 -0
  41. data/share/schemas/prick/data.sql +1 -2
  42. data/share/schemas/prick/schema.sql +0 -15
  43. data/share/schemas/prick/tables.sql +17 -0
  44. data/share/schemas/public/.keep +0 -0
  45. data/share/schemas/public/build.yml +14 -0
  46. data/share/schemas/public/schema.sql +3 -0
  47. data/test_assorted +192 -0
  48. data/test_feature +112 -0
  49. data/test_single_dev +83 -0
  50. metadata +34 -61
@@ -0,0 +1,2 @@
1
+ -- Generated by migra(1). Please don't touch. Customize the migration in migrate.sql instead
2
+ --
@@ -0,0 +1,2 @@
1
+ -- Customize your migrations here
2
+ --
@@ -0,0 +1,3 @@
1
+ -- Generated by prick(1) via migra(1). Please don't touch. Customize the
2
+ -- migration in migrate.sql instead
3
+ --
@@ -0,0 +1,6 @@
1
+ # Auto-generated by prick(1). Please don't touch
2
+ #
3
+ # This file is auto-generated from the set of features.yml files in the
4
+ # migration so that order of initialization is correct
5
+ #
6
+ ---
@@ -0,0 +1,5 @@
1
+ -- Customize your migrations here
2
+ --
3
+
4
+ -- Only if no table changes
5
+ --\i diff.sql
@@ -0,0 +1,5 @@
1
+ # You can customize this file
2
+ #
3
+ ---
4
+ - features
5
+ - migrate.sql
@@ -0,0 +1,14 @@
1
+ # Default schema files
2
+ #
3
+ ---
4
+ - schema
5
+ - roles
6
+ - types
7
+ - tables
8
+ - data
9
+ - constraints
10
+ - indexes
11
+ - views
12
+ - functions
13
+ - comments
14
+ - grants
@@ -0,0 +1,5 @@
1
+
2
+ drop schema if exists [<SCHEMA>] cascade;
3
+ create schema [<SCHEMA>];
4
+
5
+ set search_path to [<SCHEMA>];
@@ -0,0 +1,3 @@
1
+ ---
2
+ - prick
3
+ - public
@@ -0,0 +1,14 @@
1
+ # Default schema files
2
+ #
3
+ ---
4
+ - schema
5
+ - roles
6
+ - types
7
+ - tables
8
+ - data
9
+ - constraints
10
+ - indexes
11
+ - views
12
+ - functions
13
+ - comments
14
+ - grants
@@ -1,7 +1,6 @@
1
-
2
-
3
1
  -- Auto-generated file. Don't touch
4
2
  --
3
+
5
4
  COPY prick.versions (id, custom, major, minor, patch, pre, feature, version) FROM stdin;
6
5
  1 \N 0 0 0 \N \N 0.0.0
7
6
  \.
@@ -1,20 +1,5 @@
1
1
 
2
- -- Controlled by prick(1). Don't touch
3
- --
4
-
5
2
  drop schema if exists prick cascade;
6
3
  create schema prick;
7
4
 
8
5
  set search_path to prick;
9
-
10
- create table versions (
11
- id integer generated by default as identity primary key,
12
- custom varchar,
13
- major integer not null,
14
- minor integer not null,
15
- patch integer not null,
16
- pre varchar,
17
- feature varchar,
18
- version varchar not null
19
- );
20
-
@@ -0,0 +1,17 @@
1
+
2
+ -- Controlled by prick(1). Don't touch
3
+ --
4
+
5
+ set search_path to prick;
6
+
7
+ create table versions (
8
+ id integer generated by default as identity primary key,
9
+ custom varchar,
10
+ major integer not null,
11
+ minor integer not null,
12
+ patch integer not null,
13
+ pre varchar,
14
+ feature varchar,
15
+ version varchar not null
16
+ );
17
+
File without changes
@@ -0,0 +1,14 @@
1
+ # Default schema files
2
+ #
3
+ ---
4
+ - schema
5
+ - roles
6
+ - types
7
+ - tables
8
+ - data
9
+ - constraints
10
+ - indexes
11
+ - views
12
+ - functions
13
+ - comments
14
+ - grants
@@ -0,0 +1,3 @@
1
+ set search_path to public;
2
+
3
+
@@ -0,0 +1,192 @@
1
+ #!/usr/bin/bash
2
+
3
+ function add_table() {
4
+ local name=$1
5
+ echo "create table $name (id integer);" >>schemas/public/tables.sql
6
+ git add schemas/public/tables.sql
7
+ git commit -m "Added table $name" >/dev/null
8
+ }
9
+
10
+ set -e
11
+ clear
12
+
13
+ rm -rf dir
14
+ prick --name prj init dir
15
+ echo
16
+ (
17
+ echo "*** DEVELOP ON UNNAMED RELEASES"
18
+ echo "***"
19
+
20
+ cd dir
21
+ echo "Prepare an unnamed release"
22
+ prick prepare release
23
+ echo
24
+
25
+ echo "Add table a"
26
+ add_table a
27
+ echo
28
+
29
+ echo "Bring current database up to date"
30
+ prick build
31
+ echo
32
+
33
+ echo "Prepare diff"
34
+ prick prepare diff
35
+ echo
36
+
37
+ echo "Commit diff"
38
+ git commit -am "Committed diff"
39
+ echo
40
+
41
+ echo "Update migrations"
42
+ echo "\\i diff.sql" >>releases/0.0.0/migrate.sql
43
+ git commit -am "Updated migrations.sql"
44
+ echo
45
+
46
+ echo "Create release 0.1.0"
47
+ prick create release 0.1.0
48
+ echo
49
+
50
+ echo "*** DEVELOP ON PRERELEASES"
51
+ echo "***"
52
+
53
+ echo "Create prerelease for 0.2.0"
54
+ prick create prerelease minor
55
+ echo
56
+
57
+ echo "Add table b"
58
+ add_table b
59
+ echo
60
+
61
+ echo "Bring current database up to date"
62
+ prick build
63
+ echo
64
+
65
+ echo "Prepare diff"
66
+ prick prepare diff
67
+ echo
68
+
69
+ echo "Commit diff"
70
+ git commit -am "Committed diff"
71
+ echo
72
+
73
+ echo "Update migrations"
74
+ echo "\\i diff.sql" >>releases/0.1.0/migrate.sql
75
+ git commit -am "Updated migrations.sql"
76
+ echo
77
+
78
+ echo "Create release 0.2.0"
79
+ prick create release
80
+ echo
81
+
82
+ echo "*** DEVELOP ON MIGRATIONS"
83
+ echo "***"
84
+
85
+ echo "Prepare 0.0.0 -> 0.2.0 migration"
86
+ prick prepare migration 0.0.0
87
+ echo
88
+
89
+ echo "Prepare diff"
90
+ prick prepare diff
91
+ echo
92
+
93
+ echo "Commit diff"
94
+ git commit -am "Committed diff"
95
+ echo
96
+
97
+ echo "Check migration"
98
+ prick check && echo ok || echo ej
99
+ echo
100
+
101
+ # echo "*** REBASING MIGRATIONS (bad idea)"
102
+ # echo "***"
103
+ #
104
+ # echo "Checkout 0.2.0"
105
+ # git checkout 0.2.0
106
+ #
107
+ # echo "Prepare an unnamed release"
108
+ # prick prepare release
109
+ # echo
110
+ #
111
+ # echo "Add table c"
112
+ # add_table c
113
+ # echo
114
+ #
115
+ # echo "Bring current database up to date"
116
+ # prick build
117
+ # echo
118
+ #
119
+ # echo "Prepare diff"
120
+ # prick prepare diff
121
+ # echo
122
+ #
123
+ # echo "Commit diff"
124
+ # git commit -am "Committed diff"
125
+ # echo
126
+ #
127
+ # echo "Update migrations"
128
+ # echo "\\i diff.sql" >>releases/0.2.0/migrate.sql
129
+ # git commit -am "Updated migrations.sql"
130
+ # echo
131
+ #
132
+ # echo "Create release 0.3.0"
133
+ # prick create release minor
134
+ # echo
135
+ #
136
+ # echo "Checkout 0.0.0_0.2.0"
137
+ # git checkout 0.0.0_0.2.0
138
+ #
139
+ # echo "Rebase migration"
140
+ # prick prepare migration 0.3.0
141
+
142
+
143
+
144
+
145
+
146
+ echo "Checkout 0.2.0"
147
+ git checkout 0.2.0
148
+ echo
149
+
150
+ echo "Create feature_a"
151
+ prick create feature feature_a
152
+ echo
153
+ exit
154
+
155
+ echo "Create prerelease 0.1.0.pre.1"
156
+ prick create prerelease minor
157
+ echo
158
+
159
+ echo "Increment prerelease"
160
+ prick create prerelease
161
+ echo
162
+
163
+ echo "Release (0.1.0)"
164
+ prick create release
165
+ echo
166
+
167
+ echo "Create release 0.2.0"
168
+ prick create release 0.2.0
169
+ echo
170
+
171
+ echo "Prepare migration"
172
+ prick prepare migration 0.0.0
173
+ echo
174
+
175
+ echo "Create migration"
176
+ prick create migration
177
+ echo
178
+ #
179
+ # echo "Create release 0.3.0"
180
+ # git checkout 0.2.0
181
+ # prick create release 0.3.0
182
+ # echo
183
+ #
184
+ # echo "Retarget 0.0.0 -> 0.3.0"
185
+ # git checkout 0.0.0_0.2.0
186
+ # prick retarget 0.3.0
187
+ # echo
188
+
189
+ tree -a -I .git
190
+ )
191
+
192
+
@@ -0,0 +1,112 @@
1
+ #!/usr/bin/bash
2
+
3
+ function add_table() {
4
+ local name=$1
5
+ echo "create table $name (id integer);" >>schemas/public/tables.sql
6
+ git add schemas/public/tables.sql
7
+ git commit -m "Added table $name" >/dev/null
8
+ }
9
+
10
+ set -e
11
+ clear
12
+
13
+ rm -rf dir
14
+ prick --name prj init dir
15
+ echo
16
+ (
17
+ cd dir
18
+
19
+ echo "*** FEATURE"
20
+ echo "***"
21
+
22
+ echo "Create feature_a"
23
+ prick create feature feature_a
24
+ echo
25
+
26
+ echo "Add table a"
27
+ add_table a
28
+ echo
29
+
30
+ echo "Bring current database up to date"
31
+ prick build
32
+ echo
33
+
34
+ echo "Prepare diff"
35
+ prick prepare diff
36
+ echo
37
+
38
+ echo "Commit diff"
39
+ git commit -am "Committed diff"
40
+ echo
41
+
42
+ echo "Update migrate.sql"
43
+ echo "\\i diff.sql" >>releases/0.0.0/feature_a/migrate.sql
44
+ git commit -am "Updated migrate.sql"
45
+ echo
46
+
47
+ echo "Checkout 0.0.0"
48
+ git checkout 0.0.0
49
+
50
+ echo "Create prerelease 0.1.0.pre.1"
51
+ prick create prerelease minor
52
+ echo
53
+
54
+ echo "Include feature_a"
55
+ prick include feature 0.0.0_feature_a
56
+
57
+ echo "Add table b"
58
+ add_table b
59
+ echo
60
+
61
+ echo "Bring current database up to date"
62
+ prick build
63
+ echo
64
+
65
+ echo "Prepare diff"
66
+ prick prepare diff
67
+ echo
68
+
69
+ echo "Update migrate.sql"
70
+ echo "\\i diff.sql" >>releases/0.0.0/migrate.sql
71
+ git commit -am "Updated migrate.sql"
72
+ echo
73
+
74
+ echo "Release (0.1.0)"
75
+ prick create release
76
+ echo
77
+
78
+ echo "Build 0.0.0"
79
+ prick build 0.0.0
80
+
81
+ echo "Load 0.0.0 into project database"
82
+ prick load -d prj 0.0.0
83
+
84
+ echo "Upgrade"
85
+ prick upgrade
86
+
87
+ exit
88
+
89
+ # echo "Increment prerelease"
90
+ # prick create prerelease
91
+ # echo
92
+ #
93
+ # echo "Create release 0.2.0"
94
+ # prick create release 0.2.0
95
+ # echo
96
+ #
97
+ # echo "Prepare migration"
98
+ # prick prepare migration 0.0.0
99
+ # echo
100
+ #
101
+ # echo "Create migration"
102
+ # prick create migration
103
+ # echo
104
+ # echo "Prepare an unnamed release"
105
+ # prick prepare release
106
+ # echo
107
+ #
108
+
109
+ tree -a -I .git
110
+ )
111
+
112
+