Skip to content

Commit 4f88fc1

Browse files
authored
Merge pull request #7 from datalust/dev
Release
2 parents 5510502 + f9980f3 commit 4f88fc1

24 files changed

+1083
-58
lines changed

Build.ps1

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,37 @@ function Execute-Tests
4747
popd
4848
}
4949

50-
function Publish-Artifacts($version)
50+
function Create-ArtifactDir
5151
{
5252
mkdir ./artifacts
53-
mv ./setup/Datalust.Piggy.Setup/bin/Release/piggy.msi ./artifacts/piggy-$version-pre.msi
53+
}
54+
55+
function Publish-Gzips($version)
56+
{
57+
$rids = @("ubuntu.14.04-x64", "ubuntu.16.04-x64", "rhel.7-x64", "osx.10.12-x64")
58+
foreach ($rid in $rids) {
59+
& dotnet publish src/Datalust.Piggy/Datalust.Piggy.csproj -c Release -r $rid
60+
if($LASTEXITCODE -ne 0) { exit 3 }
61+
62+
# Make sure the archive contains a reasonable root filename
63+
mv ./src/Datalust.Piggy/bin/Release/netcoreapp1.1/$rid/publish/ ./src/Datalust.Piggy/bin/Release/netcoreapp1.1/$rid/piggy-$version-$rid/
64+
65+
& ./build/7-zip/7za.exe a -ttar piggy-$version-$rid.tar ./src/Datalust.Piggy/bin/Release/netcoreapp1.1/$rid/piggy-$version-$rid/
66+
if($LASTEXITCODE -ne 0) { exit 3 }
67+
68+
# Back to the original directory name
69+
mv ./src/Datalust.Piggy/bin/Release/netcoreapp1.1/$rid/piggy-$version-$rid/ ./src/Datalust.Piggy/bin/Release/netcoreapp1.1/$rid/publish/
70+
71+
& ./build/7-zip/7za.exe a -tgzip ./artifacts/piggy-$version-$rid.tar.gz piggy-$version-$rid.tar
72+
if($LASTEXITCODE -ne 0) { exit 3 }
73+
74+
rm piggy-$version-$rid.tar
75+
}
76+
}
77+
78+
function Publish-Msi($version)
79+
{
80+
mv ./setup/Datalust.Piggy.Setup/bin/Release/piggy.msi ./artifacts/piggy-$version.msi
5481
}
5582

5683
Push-Location $PSScriptRoot
@@ -63,6 +90,8 @@ Update-AssemblyInfo($version)
6390
Update-WixVersion($version)
6491
Execute-MSBuild
6592
Execute-Tests
66-
Publish-Artifacts($version)
93+
Create-ArtifactDir
94+
Publish-Gzips($version)
95+
Publish-Msi($version)
6796

6897
Pop-Location

README.md

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,29 @@
22

33
A friendly PostgreSQL script runner in the spirit of [DbUp](https://github.com/DbUp/DbUp).
44

5-
[![Build status](https://ci.appveyor.com/api/projects/status/889gkdpvjbjuhkfg?svg=true)](https://ci.appveyor.com/project/datalust/piggy)
5+
[![Build status](https://ci.appveyor.com/api/projects/status/889gkdpvjbjuhkfg?svg=true)](https://ci.appveyor.com/project/datalust/piggy) [![Join the chat at https://gitter.im/datalust/piggy](https://img.shields.io/gitter/room/datalust/piggy.svg)](https://gitter.im/datalust/piggy)
66

77
### What is Piggy?
88

99
Piggy is a simple command-line tool for managing schema and data changes to PostgreSQL databases. Piggy looks for `.sql` files in a directory and applies them to the database in order, using transactions and a change log table to ensure each script runs only once per database.
1010

1111
### Installation
1212

13-
Piggy is available as a Windows MSI installer from [the releases page](https://github.com/datalust/piggy/releases). Linux and macOS are supported, but currently require the `Datalust.Piggy` project in this repository to be built from source.
13+
Piggy is available for Windows, macOS and Linux from [the releases page](https://github.com/datalust/piggy/releases). Download the MSI or archive file for [your platform](https://docs.microsoft.com/en-us/dotnet/core/rid-catalog). If your platform of choice isn't listed, please [raise an issue here](https://github.com/datalust/piggy/issues) so that we can add it.
1414

15-
### Organizing change scripts
15+
### Workflow
1616

17-
Your `.sql` files should be named so that they will sort lexicographically in the order they need to be executed:
17+
To manage database updates with Piggy, write SQL scripts to make changes, rather than applying changes directly.
18+
19+
Organize change scripts on the file system under a _script root_ directory. Name files so that they sort lexicographically in the order in which they need to be executed:
1820

1921
```
2022
001-create-schema.sql
2123
002-create-users-table.sql
2224
003-...
2325
```
2426

25-
If the scripts are arranged in subfolders, these can be ordered as well:
27+
If the scripts are arranged in subdirectories, these must be ordered by name as well:
2628

2729
```
2830
v1/
@@ -33,21 +35,21 @@ v2/
3335
001-rename-users-table.sql
3436
```
3537

36-
Each script is just regular SQL with any DDL or DML statements required to make a change to the database.
37-
38-
### Applying scripts
39-
40-
Scripts must be applied starting from a _script root_. Piggy searches for `.sql` files and generates script names like `/v1/001-create-schema.sql` using each script's filename relative to the script root. These relative filenames are checked against the change log table to determine which of them need to be run.
38+
Piggy enumerates `.sql` files and generates names like `/v1/001-create-schema.sql` using each script's filename relative to the script root. These relative names are checked against the change log table to determine which of them need to be run.
4139

42-
The script root is specified with `-s`. Other parameters identify the database server host, the database name, username and password:
40+
To bring a database up to date, run `piggy up`, providing the script root, host, database name, username and password:
4341

4442
```
45-
piggy apply -s <scripts> -h <host> -d <database> -u <username> -p <password>
43+
piggy up -s <scripts> -h <host> -d <database> -u <username> -p <password>
4644
```
4745

4846
If the database does not exist, Piggy will create it using sensible defaults. To opt out of this behavior, add the `--no-create` flag.
4947

50-
For more detailed usage information, run `piggy help apply`; to see all available commands run `piggy help`.
48+
Over time, as your application grows, create new scripts to move the database forwards - don't edit the existing ones, since they've already been applied and will be ignored by Piggy.
49+
50+
Piggy can be used to update from any previous schema version to the current one: scripts that have already been run on a database are ignored, so only necessary scripts are applied.
51+
52+
For more detailed usage information, run `piggy help up`; to see all available commands run `piggy help`.
5153

5254
### Transactions
5355

@@ -64,7 +66,7 @@ as the first line of the script.
6466
Piggy uses `$var$` syntax for replaced variables:
6567

6668
```sql
67-
create table $schema$.users;
69+
create table $schema$.users (name varchar(140) not null);
6870
insert into users (name) values ('$admin$');
6971
```
7072

@@ -73,9 +75,9 @@ Values are inserted using pure text substitution: no escaping or other processin
7375
Variables are supplied on the command-line with the `-v` flag:
7476

7577
```
76-
piggy apply ... -v schema=myapp -v admin=myuser
78+
piggy up ... -v schema=myapp -v admin=myuser
7779
```
7880

7981
### Change log
8082

81-
The change log is stored in the target database in `piggy.changes`. The `piggy log` command can be used to view applied change scripts.
83+
The change log is stored in the target database in `piggy.changes`. The `piggy log` command is used to view applied change scripts.

appveyor.yml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,13 @@ build_script:
55
- ps: ./Build.ps1
66
test: off
77
artifacts:
8-
- path: artifacts/*.msi
8+
- path: artifacts/piggy-*.msi
9+
- path: artifacts/piggy-*.tar.gz
910
deploy:
1011
- provider: GitHub
1112
auth_token:
1213
secure: Bo3ypKpKFxinjR9ShkNekNvkob2iklHJU+UlYyfHtcFFIAa58SV2TkEd0xWxz633
13-
artifact: /piggy-.*\.msi/
14+
artifact: /piggy-.*\.(msi|tar\.gz)/
1415
tag: v$(appveyor_build_version)
1516
on:
1617
branch: master

build/7-zip/7za.dll

241 KB
Binary file not shown.

build/7-zip/7za.exe

638 KB
Binary file not shown.

build/7-zip/7zxa.dll

138 KB
Binary file not shown.

build/7-zip/Far/7-ZipEng.hlf

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
.Language=English,English
2+
.PluginContents=7-Zip Plugin
3+
4+
@Contents
5+
$^#7-Zip Plugin 16.04#
6+
$^#Copyright (c) 1999-2016 Igor Pavlov#
7+
This FAR module performs transparent #archive# processing.
8+
Files in the archive are handled in the same manner as if they
9+
were in a folder.
10+
11+
~Extracting from the archive~@Extract@
12+
13+
~Add files to the archive~@Update@
14+
15+
~7-Zip Plugin configuration~@Config@
16+
17+
18+
Web site: #www.7-zip.org#
19+
20+
@Extract
21+
$ #Extracting from the archive#
22+
23+
In this dialog you may enter extracting mode.
24+
25+
Path mode
26+
27+
#Full pathnames# Extract files with full pathnames.
28+
29+
#Current pathnames# Extract files with all relative paths.
30+
31+
#No pathnames# Extract files without folder paths.
32+
33+
34+
Overwrite mode
35+
36+
#Ask before overwrite# Ask before overwriting existing files.
37+
38+
#Overwrite without prompt# Overwrite existing files without prompt.
39+
40+
#Skip existing files# Skip extracting of existing files.
41+
42+
43+
Files
44+
45+
#Selected files# Extract only selected files.
46+
47+
#All files# Extract all files from archive.
48+
49+
@Update
50+
$ #Add files to the archive#
51+
52+
This dialog allows you to specify options for process of updating archive.
53+
54+
55+
Compression method
56+
57+
#Store# Files will be copied to archive without compression.
58+
59+
#Normal# Files will be compressed.
60+
61+
#Maximum# Files will be compressed with method that gives
62+
maximum compression ratio.
63+
64+
65+
Update mode
66+
67+
#Add and replace files# Add all specified files to the archive.
68+
69+
#Update and add files# Update older files in the archive and add
70+
files that are new to the archive.
71+
72+
#Freshen existing files# Update specified files in the archive that
73+
are older than the selected disk files.
74+
75+
#Synchronize files# Replace specified files only if
76+
added files are newer. Always add those
77+
files, which are not present in the
78+
archive. Delete from archive those files,
79+
which are not present on the disk.
80+
81+
@Config
82+
$ #7-Zip Plugin configuration#
83+
In this dialog you may change following parameters:
84+
85+
#Plugin is used by default# Plugin is used by default.

0 commit comments

Comments
 (0)