prick 0.2.0 → 0.7.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 (58) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +6 -5
  3. data/Gemfile +4 -1
  4. data/TODO +10 -0
  5. data/doc/prick.txt +114 -0
  6. data/exe/prick +328 -402
  7. data/lib/ext/fileutils.rb +18 -0
  8. data/lib/ext/forward_method.rb +18 -0
  9. data/lib/ext/shortest_path.rb +44 -0
  10. data/lib/prick.rb +20 -10
  11. data/lib/prick/branch.rb +254 -0
  12. data/lib/prick/builder.rb +164 -0
  13. data/lib/prick/cache.rb +34 -0
  14. data/lib/prick/command.rb +19 -11
  15. data/lib/prick/constants.rb +122 -48
  16. data/lib/prick/database.rb +28 -20
  17. data/lib/prick/diff.rb +125 -0
  18. data/lib/prick/exceptions.rb +15 -3
  19. data/lib/prick/git.rb +77 -30
  20. data/lib/prick/head.rb +183 -0
  21. data/lib/prick/migration.rb +40 -200
  22. data/lib/prick/program.rb +493 -0
  23. data/lib/prick/project.rb +523 -351
  24. data/lib/prick/rdbms.rb +4 -13
  25. data/lib/prick/schema.rb +16 -90
  26. data/lib/prick/share.rb +64 -0
  27. data/lib/prick/state.rb +192 -0
  28. data/lib/prick/version.rb +62 -29
  29. data/libexec/strip-comments +33 -0
  30. data/make_releases +48 -345
  31. data/make_schema +10 -0
  32. data/prick.gemspec +14 -23
  33. data/share/diff/diff.after-tables.sql +4 -0
  34. data/share/diff/diff.before-tables.sql +4 -0
  35. data/share/diff/diff.tables.sql +8 -0
  36. data/share/migration/diff.tables.sql +8 -0
  37. data/share/migration/features.yml +6 -0
  38. data/share/migration/migrate.sql +3 -0
  39. data/share/migration/migrate.yml +8 -0
  40. data/share/migration/tables.sql +3 -0
  41. data/share/schema/build.yml +14 -0
  42. data/share/schema/schema.sql +5 -0
  43. data/share/schema/schema/build.yml +3 -0
  44. data/share/schema/schema/prick/build.yml +14 -0
  45. data/share/schema/schema/prick/data.sql +7 -0
  46. data/share/schema/schema/prick/schema.sql +5 -0
  47. data/share/{schemas/prick/schema.sql → schema/schema/prick/tables.sql} +2 -5
  48. data/{file → share/schema/schema/public/.keep} +0 -0
  49. data/share/schema/schema/public/build.yml +14 -0
  50. data/share/schema/schema/public/schema.sql +3 -0
  51. data/test_assorted +192 -0
  52. data/test_feature +112 -0
  53. data/test_refactor +34 -0
  54. data/test_single_dev +83 -0
  55. metadata +43 -68
  56. data/lib/prick/build.rb +0 -376
  57. data/lib/prick/migra.rb +0 -22
  58. data/share/schemas/prick/data.sql +0 -8
data/make_schema ADDED
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/bash
2
+
3
+ SHARE_DIR=share/schemas/schema
4
+ mkdir -p $SHARE_DIR
5
+ NAMES="roles types tables data constraints indexes views functions comments grants"
6
+ for name in $NAMES; do
7
+ name=$name.sql
8
+ file=$SHARE_DIR/$name
9
+ echo -ne "-- ${name}\n\nset search_path to [<SCHEMA>];\n\n" >$file
10
+ done
data/prick.gemspec CHANGED
@@ -1,7 +1,10 @@
1
1
 
2
- lib = File.expand_path("../lib", __FILE__)
3
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require "prick/version"
2
+ #$LOAD_PATH.unshift("/home/clr/prj/shellopts/lib")
3
+
4
+ #lib = File.expand_path("../lib", __FILE__)
5
+ #$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
+ #require "prick/version"
7
+ require_relative 'lib/prick/version'
5
8
 
6
9
  Gem::Specification.new do |spec|
7
10
  spec.name = "prick"
@@ -9,22 +12,14 @@ Gem::Specification.new do |spec|
9
12
  spec.authors = ["Claus Rasmussen"]
10
13
  spec.email = ["claus.l.rasmussen@gmail.com"]
11
14
 
12
- spec.summary = %q{prick gem}
13
- spec.description = %q{prick gem}
15
+ spec.summary = "A release control and management system for postgresql"
16
+ spec.description = "A release control and management system for postgresql"
14
17
  spec.homepage = "http://www.nowhere.com/"
18
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.7.1")
15
19
 
16
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
17
- # to allow pushing to a single host or delete this section to allow pushing to any host.
18
- # if spec.respond_to?(:metadata)
19
- # spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
20
- #
21
- # spec.metadata["homepage_uri"] = spec.homepage
22
- # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
23
- # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
24
- # else
25
- # raise "RubyGems 2.0 or newer is required to protect against " \
26
- # "public gem pushes."
27
- # end
20
+ # spec.metadata["homepage_uri"] = spec.homepage
21
+ # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
22
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
28
23
 
29
24
  # Specify which files should be added to the gem when it is released.
30
25
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -35,12 +30,8 @@ Gem::Specification.new do |spec|
35
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
36
31
  spec.require_paths = ["lib"]
37
32
 
38
- spec.add_development_dependency "bundler", "~> 2.1"
39
- spec.add_development_dependency "rake", "~> 10.0"
40
- spec.add_development_dependency "rspec", "~> 3.0"
41
-
42
- spec.add_dependency "pg"
43
- spec.add_dependency "shellopts", "2.0.0.pre.11"
33
+ # spec.add_dependency "pg"
34
+ spec.add_dependency "shellopts", "2.0.0.pre.14"
44
35
  spec.add_dependency "semantic"
45
36
  spec.add_dependency "indented_io"
46
37
  end
@@ -0,0 +1,4 @@
1
+ -- Generated by prick(1) via migra(1). Please don't touch.
2
+ --
3
+ -- It should not be necessary to change this file as it doesn't contain data changes
4
+ --
@@ -0,0 +1,4 @@
1
+ -- Generated by prick(1) via migra(1). Please don't touch.
2
+ --
3
+ -- It should not be necessary to change this file as it doesn't contain data changes
4
+ --
@@ -0,0 +1,8 @@
1
+ -- Generated by prick(1) via migra(1). Please don't touch.
2
+ --
3
+ -- This file contains changes that can touch existing data in the database that
4
+ -- needs speciel treatment in the migrate.sql
5
+ --
6
+ -- Note that this file is not executed by prick by default and that it is not
7
+ -- added to the Git repo when it changes. You have to do that manually
8
+ --
@@ -0,0 +1,8 @@
1
+ -- Generated by prick(1) via migra(1). Please don't touch.
2
+ --
3
+ -- This file contains changes that can touch existing data in the database that
4
+ -- needs speciel treatment in the migrate.sql
5
+ --
6
+ -- Note that this file is not executed by prick by default and that it is not
7
+ -- added to the Git repo when it changes. You have to do that manually
8
+ --
@@ -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,3 @@
1
+ -- Customize your migrations here but
2
+ --
3
+
@@ -0,0 +1,8 @@
1
+ # You can customize this file
2
+ #
3
+ ---
4
+ - features
5
+ - diff.before-tables.sql
6
+ - tables
7
+ - migrate.sql
8
+ - diff.after-tables.sql
@@ -0,0 +1,3 @@
1
+ -- Placeholder for table changes. After you prepared a diff, you should inspect
2
+ -- diff.table.sql and incorporate the changes here
3
+ --
@@ -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
@@ -0,0 +1,7 @@
1
+ -- Auto-generated file. Don't touch
2
+ --
3
+
4
+ COPY prick.versions (id, fork, major, minor, patch, pre, feature, version) FROM stdin;
5
+ 1 \N 0 0 0 \N \N 0.0.0
6
+ \.
7
+
@@ -0,0 +1,5 @@
1
+
2
+ drop schema if exists prick cascade;
3
+ create schema prick;
4
+
5
+ set search_path to prick;
@@ -2,18 +2,15 @@
2
2
  -- Controlled by prick(1). Don't touch
3
3
  --
4
4
 
5
- drop schema if exists prick cascade;
6
- create schema prick;
7
-
8
5
  set search_path to prick;
9
6
 
10
7
  create table versions (
11
8
  id integer generated by default as identity primary key,
12
- custom varchar,
9
+ fork varchar,
13
10
  major integer not null,
14
11
  minor integer not null,
15
12
  patch integer not null,
16
- pre varchar,
13
+ pre integer,
17
14
  feature varchar,
18
15
  version varchar not null
19
16
  );
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
+
data/test_assorted ADDED
@@ -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
+
data/test_feature ADDED
@@ -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
+