prick 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7a41038c7beeb2bb1503ccb199cc45622d6fbe28e113003b98e8e78e10658a37
4
+ data.tar.gz: 59cb5055863ce2cd63ad9db5a2adf9a0de33d4386bca210dd8e9f25f602bb5e1
5
+ SHA512:
6
+ metadata.gz: 0b19d6f150e840101f60aa9337583257a0f72e36e2eb7a84b1403063b274099e7a27716aecd2ccaaaf09484a4f5d4b1f9da6eebde340fe9b69da8bab8342528e
7
+ data.tar.gz: 7b71790136d8de6e2f3c77a58fb5d1e432bbbe6f0c910ada86608e05f759c8ea68d255f1cc038ce2b5efebfb7e379f0bb2f607a94cfd99b5f26cf3665f135130
@@ -0,0 +1,28 @@
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
+ # Temporary ignores
23
+ /releases/
24
+ /migrations/
25
+ /prick.sh
26
+
27
+ # Ignore bundle binstubs
28
+ /bin/prick
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
@@ -0,0 +1 @@
1
+ ruby-2.7.1
@@ -0,0 +1,7 @@
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
data/Gemfile ADDED
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
+
5
+ # Specify your gem's dependencies in prick.gemspec
6
+ gemspec
@@ -0,0 +1,35 @@
1
+ # Prick
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/prick`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'prick'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install prick
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/prick.
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "prick"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,17 @@
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
+
@@ -0,0 +1,98 @@
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
+
@@ -0,0 +1 @@
1
+ https://github.com/djrobstep/migra
@@ -0,0 +1,172 @@
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
+
@@ -0,0 +1,116 @@
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