prick 0.18.0 → 0.20.2

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 (112) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +10 -4
  3. data/README.md +7 -7
  4. data/Rakefile +3 -1
  5. data/TODO +13 -11
  6. data/bin/console +2 -1
  7. data/doc/build-yml.txt +14 -0
  8. data/exe/prick +264 -28
  9. data/lib/builder/batch.rb +147 -0
  10. data/lib/builder/builder.rb +122 -0
  11. data/lib/builder/node.rb +189 -0
  12. data/lib/builder/node_pool.rb +105 -0
  13. data/lib/builder/parser.rb +120 -0
  14. data/lib/local/command.rb +193 -0
  15. data/lib/{prick → local}/git.rb +148 -22
  16. data/lib/local/timer.rb +98 -0
  17. data/lib/prick/constants.rb +54 -66
  18. data/lib/prick/diff.rb +28 -18
  19. data/lib/prick/prick_version.rb +161 -0
  20. data/lib/prick/state.rb +80 -165
  21. data/lib/prick/version.rb +2 -163
  22. data/lib/prick.rb +43 -27
  23. data/lib/share/init/.gitignore +10 -0
  24. data/lib/share/init/.prick-context +2 -0
  25. data/lib/share/init/.rspec +3 -0
  26. data/{share/schema/schema/public → lib/share/init/migration}/.keep +0 -0
  27. data/lib/share/init/prick.yml +6 -0
  28. data/lib/share/init/schema/.keep +0 -0
  29. data/lib/share/init/schema/build.yml +2 -0
  30. data/lib/share/init/schema/prick/.keep +0 -0
  31. data/lib/share/init/schema/prick/build.yml +5 -0
  32. data/lib/share/init/schema/prick/data.sql +6 -0
  33. data/{share/schema → lib/share/init}/schema/prick/tables.sql +2 -3
  34. data/lib/share/init/schema/public/.keep +0 -0
  35. data/lib/share/init/spec/prick_helper.rb +1 -0
  36. data/lib/share/init/spec/prick_spec.rb +6 -0
  37. data/lib/share/init/spec/spec_helper.rb +50 -0
  38. data/lib/share/migrate/migration/build.yml +4 -0
  39. data/lib/share/migrate/migration/diff.after-tables.sql +0 -0
  40. data/lib/share/migrate/migration/diff.before-tables.sql +0 -0
  41. data/lib/share/migrate/migration/diff.tables.sql +0 -0
  42. data/lib/subcommand/prick-build.rb +55 -0
  43. data/lib/subcommand/prick-create.rb +78 -0
  44. data/lib/subcommand/prick-drop.rb +25 -0
  45. data/lib/subcommand/prick-fox.rb +62 -0
  46. data/lib/subcommand/prick-init.rb +46 -0
  47. data/lib/subcommand/prick-make.rb +202 -0
  48. data/lib/subcommand/prick-migrate.rb +37 -0
  49. data/lib/subcommand/prick-release.rb +23 -0
  50. data/lib/subcommand/prick-setup.rb +20 -0
  51. data/lib/subcommand/prick-teardown.rb +18 -0
  52. data/prick.gemspec +43 -16
  53. metadata +161 -72
  54. data/.gitignore +0 -29
  55. data/.travis.yml +0 -7
  56. data/doc/create_release.txt +0 -17
  57. data/doc/flow.txt +0 -98
  58. data/doc/migra +0 -1
  59. data/doc/migrations.txt +0 -172
  60. data/doc/notes.txt +0 -116
  61. data/doc/prick.txt +0 -114
  62. data/doc/sh.prick +0 -316
  63. data/lib/ext/algorithm.rb +0 -14
  64. data/lib/ext/fileutils.rb +0 -26
  65. data/lib/ext/forward_method.rb +0 -18
  66. data/lib/ext/pg.rb +0 -18
  67. data/lib/ext/shortest_path.rb +0 -44
  68. data/lib/prick/archive.rb +0 -124
  69. data/lib/prick/branch.rb +0 -254
  70. data/lib/prick/builder.rb +0 -205
  71. data/lib/prick/cache.rb +0 -34
  72. data/lib/prick/command.rb +0 -102
  73. data/lib/prick/database.rb +0 -82
  74. data/lib/prick/dsort.rb +0 -151
  75. data/lib/prick/ensure.rb +0 -119
  76. data/lib/prick/exceptions.rb +0 -25
  77. data/lib/prick/head.rb +0 -183
  78. data/lib/prick/migration.rb +0 -70
  79. data/lib/prick/program.rb +0 -506
  80. data/lib/prick/project.rb +0 -626
  81. data/lib/prick/rdbms.rb +0 -137
  82. data/lib/prick/schema.rb +0 -27
  83. data/lib/prick/share.rb +0 -64
  84. data/libexec/strip-comments +0 -33
  85. data/make_releases +0 -72
  86. data/make_schema +0 -10
  87. data/share/diff/diff.after-tables.sql +0 -4
  88. data/share/diff/diff.before-tables.sql +0 -4
  89. data/share/diff/diff.tables.sql +0 -8
  90. data/share/features/diff.sql +0 -2
  91. data/share/features/feature/diff.sql +0 -2
  92. data/share/features/feature/migrate.sql +0 -2
  93. data/share/features/features.sql +0 -2
  94. data/share/features/features.yml +0 -2
  95. data/share/features/migrations.sql +0 -4
  96. data/share/gitignore +0 -2
  97. data/share/migration/diff.tables.sql +0 -8
  98. data/share/migration/features.yml +0 -6
  99. data/share/migration/migrate.sql +0 -3
  100. data/share/migration/migrate.yml +0 -8
  101. data/share/migration/tables.sql +0 -3
  102. data/share/schema/build.yml +0 -14
  103. data/share/schema/schema/build.yml +0 -3
  104. data/share/schema/schema/prick/build.yml +0 -14
  105. data/share/schema/schema/prick/data.sql +0 -7
  106. data/share/schema/schema/prick/schema.sql +0 -3
  107. data/share/schema/schema/public/build.yml +0 -13
  108. data/share/schema/schema.sql +0 -3
  109. data/test_assorted +0 -192
  110. data/test_feature +0 -112
  111. data/test_refactor +0 -34
  112. data/test_single_dev +0 -83
data/.gitignore DELETED
@@ -1,29 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /rdoc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
- /spec/tmp/
10
-
11
- # rspec failure tracking
12
- .rspec_status
13
-
14
- # Ignore auto-generated main file
15
- /main
16
-
17
- # Ignore Gemfile.lock. See https://stackoverflow.com/questions/4151495/should-gemfile-lock-be-included-in-gitignore
18
- /Gemfile.lock
19
-
20
- # Put your personal ignore files in /home/clr/.config/git/ignore
21
-
22
- # Ignore bundle binstubs
23
- /bin/prick
24
-
25
- # Ignore development testing dir
26
- /dir
27
-
28
- # Ignore stove-away directory
29
- /hold
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- sudo: false
3
- language: ruby
4
- cache: bundler
5
- rvm:
6
- - 2.6.6
7
- before_install: gem install bundler -v 1.17.3
@@ -1,17 +0,0 @@
1
-
2
- 0.0.0
3
- feature_a
4
- feature_b
5
- feature_c
6
-
7
-
8
- branch 0.0.1.pre.1
9
- merge feature_a
10
- merge feature_b
11
-
12
-
13
-
14
-
15
-
16
-
17
-
data/doc/flow.txt DELETED
@@ -1,98 +0,0 @@
1
-
2
-
3
- Premises:
4
- o When a feature is developed, the release is not known => Features are
5
- stored in subdirectories of the base version
6
- o Because features are stored in subdirectories of the base version, releases
7
- have to live on separate branches to avoid conflicts when two releases
8
- use the same base version but different features
9
- o As a side-effect a release has a record of previous releases and features
10
- in the features/ directory
11
- o Features are relatively orthogonal and rarely cause conflicts
12
-
13
- o We want to maintain history => Files are not moved around
14
- o We want to support custom releases => Releases lives on branches
15
- o We want to be able to shortcircuit the migration chain
16
- o We want to be able to bring custom releases back into the main line =>
17
- Rebasing lives on separate branches
18
- o We want to support semantic versioning
19
-
20
-
21
- Notes:
22
- o Referring to a tag gives you a point-in-time. Referring to a branch gives
23
- you the newest version
24
- o Two kinds of migrations: Feature migrations on new releases and
25
- jump-migrations between releases
26
-
27
-
28
- Commands
29
- Developer:
30
- prick checkout 0.0.0
31
- prick feature feature_a
32
- prick checkout feature_a-0.0.0
33
- work...work...work
34
- prick commit
35
- prick checkout master
36
-
37
- Release manager:
38
- prick checkout 0.0.0
39
- prick prepare 0.0.1
40
- prick checkout 0.0.1.pre
41
- prick merge feature_a-0.0.0 (or 'prick merge feature_a' using lookup by <feature>-<base_version>)
42
-
43
- Developer:
44
- prick checkout 0.0.0
45
- prick feature feature_b
46
- prick checkout feature_b
47
- work...work...work
48
- prick commit
49
- prick checkout master
50
-
51
- Release manager:
52
- prick merge feature_b (conflicts!)
53
- asks developer to rebase to current tag
54
-
55
- Developer:
56
- prick checkout feature_b
57
- prick rebase 0.0.1.pre
58
- work...work...work
59
- prick commit
60
- prick checkout master
61
-
62
- Release manager:
63
- prick merge feature_b-0.0.1.pre
64
-
65
-
66
- Different models:
67
-
68
- PER-DIRECTORY-MIGRATION (check)
69
- migrations
70
- 0.0.0/
71
- 0.0.1/
72
- ...
73
-
74
- features/ (not 'releases' because features are nested below the base release)
75
- 0.0.0/
76
- migrate.sql (overrides everything, defaults to calling features.sql)
77
- features.sql (list of features in merge-order, maintained by prick)
78
- feature_a/
79
- merge.sql (contains functions, indexes, and other stuff that doesn't require data migration)
80
- migrate.sql (data migrations)
81
- feature_b/
82
- migrate.sql
83
-
84
- 0.0.0-customer/
85
- ...
86
-
87
- 'feature_a' branch:
88
- 0.0.0/
89
- migrate.sql (auto-generated, calls feature_a/migrate.sql)
90
- feature_a/
91
- migrate.sql
92
-
93
-
94
- SHARED-MIGRATION
95
- features/
96
- 0.0.0/
97
- migrate.sql
98
-
data/doc/migra DELETED
@@ -1 +0,0 @@
1
- https://github.com/djrobstep/migra
data/doc/migrations.txt DELETED
@@ -1,172 +0,0 @@
1
-
2
-
3
- Each release lives on a branch of it's own and its history will only show
4
- included features. Development happens on feature branches based on the release
5
-
6
- A release lives on a branch because we want to be able to create more than one
7
- release from a base release with different features and also have a single
8
- migration file with full history
9
-
10
- Features are kept on feature branches and only merged when a release is
11
- created. The migration.sql file for a feature lives in the directory of the
12
- base release. Because each feature use the same migration file, the file
13
- will be merged by git as new features are merged into the release
14
-
15
- If a feature is not included in a release, a new migration can be created -
16
- either using rebase or copy. Rebase is preferred because it maintains history but
17
- copy allows the feature to be included in other releases based on the original
18
-
19
- migrations/
20
- 0.0.0/
21
- migrate.sql
22
- migrate to 0.1.0. We know that because we're on the 0.1.0 branch.
23
- Other releases based on 0.0.0 may have different migration files
24
-
25
- prick build & load can build release files for other branches without
26
- touching the current branch. This is used when creating migrations
27
- 0.1.0/
28
- migrate-0.0.0.sql
29
-
30
- on a feature branch for 0.1.0
31
- 0.0.0/
32
- migrate.sql <- contain migrations for this feature when based on 0.0.0
33
- 0.1.0/
34
- migrate.sql <- contain migrations for this feature when based on 0.1.0
35
-
36
- Problem?
37
- 0.0.0 -> 0.0.1 -> 0.0.2 ->
38
- -> 0.0.1-special -> 0.0.2-special -> 0.0.3
39
-
40
- Der vil være merge conflicts hele vejen ned. Alternativt finde en måde at sige,
41
- at den ene branch vinder. Måske forbyde merge af release branches? Og i stedet
42
- merge features fra den anden branch manuelt? Til slut kan man lave en migration
43
- i hånden fra den anden branch
44
-
45
-
46
-
47
- DEVELOPER ALICE:
48
- create branch alice from 0.0.0
49
- work...work...work
50
- create migration
51
- commit & push
52
-
53
- DEVELOPER BOB:
54
- create branch bob from 0.0.0
55
- work...work...work
56
- create migration
57
- commit & push
58
-
59
- DEVELOPER CHARLOTTE:
60
- create branch charlotte from 0.0.0
61
- work...work...work
62
- create migration
63
- commit & push
64
-
65
- RELEASE MANAGER ERIC:
66
- set base version to 0.0.0
67
- branch to a prerelease 0.1.0. This creates a migration file in the base version
68
- merge branch alice (no conflicts). Migration file is 0.0.0/migrate.sql
69
- merge branch bob. Merges happens to 0.0.0/migrate.sql
70
- mark alice and bob branches as dead
71
- merge branch charlotte (conflicts - rolled back)
72
- adapt migration file 0.0.0->0.1.0
73
- create release 0.1.0
74
- 0.1.0 is now the new master branch
75
-
76
- DEVELOPER CHARLOTTE:
77
- checkout branch charlotte
78
- if 0.0.0 feature is not expected to be included in other 0.0.0 based releases
79
- rebase to 0.1.0 (no conflicts because 0.1.0 doesn't contain a migration file but probably can't run)
80
- else
81
- copy to 0.1.0
82
- end
83
- adapt migration file
84
- commit & push
85
-
86
- Every branch-release will have a trail of previous releases
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
-
96
- features/
97
- 0.0.0/
98
- feature_a/
99
- migrate.sql
100
- feature_b/
101
- migrate.sql # Migrate off 0.0.0
102
- 0.1.0/ # Includes feature_a
103
- migrate-0.0.0.sql # Migrate off 0.0.0
104
- feature_b/
105
- migrate.sql # Migrate off 0.1.0
106
-
107
- Creating a "branch"
108
- features/
109
- 0.0.0/
110
- feature_a/
111
- migrate.sql
112
- 0.1.0/
113
- migrate-0.0.0.sql
114
- feature_b/
115
- migrate.sql
116
-
117
-
118
-
119
-
120
-
121
-
122
-
123
-
124
-
125
- .
126
- ├── 0.0.0
127
- │ └── migrate.sql
128
- ├── 0.0.1
129
- │ ├── 0.0.0.sql
130
- │ └── migrate.sql
131
- ├── 0.0.2
132
- │ ├── 0.0.1.sql
133
- │ └── migrate.sql
134
- ├── 0.1.0
135
- │ └── 0.0.1.sql
136
- └── migrate.sql
137
-
138
-
139
- 0.0.0
140
- feature_a
141
- migrate.sql
142
- feature_b
143
- migrate.sql
144
-
145
- 0.0.1
146
- 0.0.0.sql <- 0.0.0/feature_a/migrate.sql
147
-
148
- rebasing feature_b:
149
-
150
- feature_b
151
- migrate.sql
152
-
153
-
154
-
155
-
156
-
157
-
158
-
159
-
160
-
161
-
162
- patches/
163
- my-fix-for-something/
164
- schemas/
165
- migrations/
166
- ...
167
- my-friends-fix-for-something-else/
168
- schemas/
169
- migrations/
170
- ...
171
-
172
-
data/doc/notes.txt DELETED
@@ -1,116 +0,0 @@
1
-
2
- Git mv link
3
- https://linuxctl.com/2016/03/git---preserve-history-when-moving-files/
4
-
5
- Upgrade to ruby-2.7
6
- gem update --system
7
- https://github.com/rubygems/rubygems/issues/3284
8
-
9
- Notes
10
- o name defaults to
11
- - the value of the PRICK_DATABASE environment variable
12
- - the name of the current directory
13
-
14
- Directory structure
15
- Prick uses the following directory structure:
16
-
17
- releases/
18
- Contains a <project>-<version>.tar.gz file for each release
19
-
20
- migrations/
21
-
22
- .
23
- ├── 0.0.0
24
- │ └── migrate.sql
25
- ├── 0.0.1
26
- │ ├── 0.0.0.sql
27
- │ └── migrate.sql
28
- ├── 0.0.2
29
- │ ├── 0.0.1.sql
30
- │ └── migrate.sql
31
- ├── 0.1.0
32
- │ └── 0.0.1.sql
33
- └── migrate.sql
34
-
35
- Migration files are the result of merging in migrations from the branches that this
36
- release includes. They are read-only
37
-
38
- When a migration is created, the migration file from the from-release is copied to
39
- to the to-release directory
40
-
41
-
42
-
43
- Each migration directory contains ...
44
- :::here it gets interesting:::
45
- o a file listing individual patches for this release (this keeps the git
46
- log because we don't have to move individual developer's migration
47
- directories around)
48
- o a script for resolving conflicting patches. Another option is to make
49
- a changes patch/ directory and commit them as part of the git-release
50
-
51
- patches/
52
- my-fix-for-something/
53
- schemas/
54
- migrations/
55
- ...
56
- my-friends-fix-for-something-else/
57
- schemas/
58
- migrations/
59
- ...
60
-
61
- schemas/
62
- prick/
63
- Contains the definition of the prick database schema. The schema contains
64
- a VERSIONS table and probably a PATCHES table
65
-
66
- tests/
67
-
68
- current/ -> symlink to a unique directory under patches/
69
-
70
- snapshots/
71
- Like releases but just a copy of the database
72
-
73
- TODO: Keep track of patches in the database when preparing
74
-
75
- Developing
76
- Make your changes to schemas/ and reload often
77
-
78
- You can generate migrations as you go:
79
-
80
- change some definitions
81
- run 'prick generate migration'
82
- modify generated migration file
83
- test
84
- commit
85
-
86
- Preparing
87
- Creates a new database with the version number. The database is loaded with
88
- the content of schemas/
89
-
90
- The release is then built by pulling in patches from individual developers
91
- and list them in a configuration file. Conflicts can be resolved by a script
92
-
93
- Releasing
94
- The content of schemas/ is executed on a fresh database and the result is
95
- dumped to the releases/ directory. This is the only time a release is saved.
96
- A release contains the schema and constant data but not user data
97
-
98
- Migrating
99
- The current database is updated using the scripts in migrations/
100
-
101
-
102
-
103
-
104
-
105
-
106
-
107
-
108
-
109
-
110
-
111
-
112
-
113
- Prick
114
- o creates a database and a user at the same time
115
- o creates a 'prick' schema in the database with a versions table
116
- o uses the unversioned database as work space
data/doc/prick.txt DELETED
@@ -1,114 +0,0 @@
1
-
2
-
3
- MIGRATION STATE FILES
4
- .prick-migration (State file)
5
- version: Version
6
- The target version. The result of running the migration on the base
7
- release
8
- base_version: Version
9
- Base version. Running the migration on a base release yields a release
10
- of with the same version as the `version` property
11
-
12
- The 0.0.0 version has base_version equal to nil. A Feature has version
13
- equal to its base version.
14
-
15
- Note that while a release's .prick-migration file lives in the release
16
- directory, it's .prick-features file and the migrations lives in the
17
- directory of the base release. This separation supports the
18
- single-developer workflow where the next release is not known beforehand
19
-
20
- .prick-features (State file)
21
- features: Array
22
- A list of features versions
23
-
24
- MIGRATION FILES
25
- migrate.sql
26
- features.sql
27
- diff.sql
28
-
29
-
30
- MIGRATION FILE STRUCTURE
31
- releases/
32
- 0.0.0/
33
- .prick-migration -> version: 0.0.0, base_version: nil
34
- .prick-features -> [feature_a]
35
- feature_a/
36
- .prick-migration -> version: nil, base_version: 0.0.0
37
- .prick-features -> []
38
- feature_b/ (rebased)
39
- .prick-migration -> version: 0.2.0, base_version: 0.2.0-pre.1
40
- .prick-features -> []
41
-
42
- 0.1.0/
43
- .prick-migration -> version: 0.1.0, base_version: 0.0.0
44
- feature_b/ symlinks to ../0.0.0/feature_b/
45
-
46
- 0.1.0/ (wip - single developer work flow)
47
- .prick-migration -> version: 0.1.0, base_version: 0.0.0
48
- .prick-features -> [feature_c]
49
- feature_c/
50
- ...
51
-
52
- 0.2.0/ (doing a pre-release)
53
- .prick-migration -> version: 0.2.0-pre.1, base_version: 0.1.0
54
-
55
- migrations/
56
- 0.0.0_0.1.0/
57
- .prick-migration -> version: 0.1.0, base_version: 0.0.0
58
- .prick-features -> []
59
-
60
-
61
- NOTES
62
- #
63
- # Distinguish between running a migration 0.1.0 -> 0.2.0 and running the
64
- # migration in the 0.2.0 directory in the single-developer workflow
65
- #
66
- # prick migrate
67
- # On a tag: Migrate to that tag
68
- # On a branch: Run migrations in the release directory
69
- #
70
- # prick migrate 0.2.0 <- the version number reflects where to find the migration
71
- # Runs the migration files in the release directory
72
- #
73
- # prick migrate 0.1.0
74
- # Runs the migration files in the base release directory
75
- #
76
- #
77
- # prick build
78
- # Builds the current schema into the project database
79
- #
80
- # prick build 0.1.0
81
- # Builds the given schema into a versioned database
82
-
83
-
84
-
85
-
86
-
87
-
88
-
89
-
90
-
91
-
92
-
93
-
94
-
95
- ######################
96
-
97
- PRICK FILES
98
- ./prick-version
99
- Contains just one line with the version of the prick command that should be
100
- used with this project (eg. 'prick-0.1.0'). Prick checks this file at
101
- startup and fails if the required version doesn't match the current command
102
-
103
- ./prick
104
- project_name
105
- Name of the project
106
-
107
- ./releases/*/.prick
108
- base_version
109
- The base version of this release. nil for release 0.0.0
110
- features
111
- List of features in a release based on this release. Initially empty
112
- but filled in when the directory is prepared for a subsequent release.
113
- To find the set of features in the current release, inspect the prick
114
- file of the base_version in this branch