Skip to content

Commit

Permalink
Merge branch 'main' into feat/#230-schema-casing-MkII
Browse files Browse the repository at this point in the history
  • Loading branch information
erikbra authored Jun 3, 2023
2 parents 8f92646 + 1870912 commit 53b3eb5
Show file tree
Hide file tree
Showing 83 changed files with 2,090 additions and 265 deletions.
12 changes: 6 additions & 6 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,20 @@ assignees: ''
---

**Describe the bug**
A clear and concise description of what the bug is.
<!-- A clear and concise description of what the bug is. -->

**To Reproduce**
Steps to reproduce the behavior
<!-- Steps to reproduce the behavior -->

**Expected behavior**
A clear and concise description of what you expected to happen.
<!-- A clear and concise description of what you expected to happen. -->

**Screenshots**
If applicable, add screenshots to help explain your problem.
<!-- If applicable, add screenshots to help explain your problem. -->

**Desktop (please complete the following information):**
- OS: [e.g. macOS, Linux]
- Version [e.g. 1.0.2]
- Version: [e.g. 1.0.2]

**Additional context**
Add any other context about the problem here.
<!-- Add any other context about the problem here. -->
8 changes: 4 additions & 4 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ assignees: ''
---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->

**Describe the solution you'd like**
A clear and concise description of what you want to happen.
<!-- A clear and concise description of what you want to happen. -->

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
<!-- A clear and concise description of any alternative solutions or features you've considered. -->

**Additional context**
Add any other context or screenshots about the feature request here.
<!-- Add any other context or screenshots about the feature request here. -->
86 changes: 41 additions & 45 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,21 @@ jobs:
#is-release: 'true'

steps:
- name: Setup .NET 6
uses: actions/setup-dotnet@v2
- name: Setup .NET 7
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
include-prerelease: false
dotnet-version: 7.0.x
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install GitVersion
uses: gittools/actions/gitversion/setup@v0.9.13
uses: gittools/actions/gitversion/setup@v0.10.2
with:
versionSpec: '5.x'
- name: Determine Version
id: gitversion
uses: gittools/actions/gitversion/execute@v0.9.13
uses: gittools/actions/gitversion/execute@v0.10.2

build-netcore-tool:
needs: set-version-number
Expand All @@ -45,11 +44,10 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Setup .NET 6
uses: actions/setup-dotnet@v2
- name: Setup .NET 7
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
include-prerelease: false
dotnet-version: 7.0.x
- name: Restore dependencies
run: dotnet restore
- name: Build
Expand Down Expand Up @@ -78,23 +76,22 @@ jobs:
matrix:
arch: [ "win-x64", "win-x86", "win-arm", "win-arm64",
"alpine-x64", "linux-x64", "linux-arm", "linux-arm64",
"osx-x64"
"osx-x64", "osx.11.0-x64", "osx.11.0-arm64", "osx.12-x64", "osx.12-arm64", "osx.13-x64", "osx.13-arm64"
]

steps:
- uses: actions/checkout@v3
- name: Setup .NET 6
uses: actions/setup-dotnet@v2
- name: Setup .NET 7
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
include-prerelease: false
dotnet-version: 7.0.x

- name: Publish self-contained ${{ matrix.arch }}
run: dotnet publish ./grate/grate.csproj -r ${{ matrix.arch }} -c release --self-contained -p:SelfContained=true -o ./publish/${{ matrix.arch }}/self-contained
env:
VERSION: ${{ needs.set-version-number.outputs.nuGetVersion }}

- name: Publish .NET 6 dependent ${{ matrix.arch }}
- name: Publish .NET 6/7 dependent ${{ matrix.arch }}
run: dotnet publish ./grate/grate.csproj -r ${{ matrix.arch }} -c release --no-self-contained -o ./publish/${{ matrix.arch }}/dependent
env:
VERSION: ${{ needs.set-version-number.outputs.nuGetVersion }}
Expand Down Expand Up @@ -122,7 +119,7 @@ jobs:
if: ${{ needs.set-version-number.outputs.is-release == 'true' }}
strategy:
matrix:
arch: [ "win-x64" ]
arch: [ "win-x64", "win-arm64" ]

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -164,15 +161,15 @@ jobs:


- name: Log in to the Container registry
uses: docker/login-action@49ed152c8eca782a232dede0303416e8f356c37b
uses: docker/login-action@f4ef78c080cd8ba55a85445d5b36e214a81df20a
with:
#registry: ${{ env.REGISTRY }}
username: ${{ github.repository_owner}}
password: ${{ secrets.DOCKER_HUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@69f6fc9d46f2f8bf0d5491e4aabe0bb8c6a4678a
uses: docker/metadata-action@c4ee3adeed93b1fa6a762f209fb01608c1a22f1e
with:
tags: |
type=semver,pattern={{version}}
Expand All @@ -184,7 +181,7 @@ jobs:


- name: Build and push Docker image
uses: docker/build-push-action@c84f38281176d4c9cdb1626ffafcd6b3911b5d94
uses: docker/build-push-action@3b5e8027fcad23fda98b2e3ac259d8d67585f671
with:
context: ./installers/docker/
push: true
Expand Down Expand Up @@ -227,31 +224,31 @@ jobs:
name: grate_${{ needs.set-version-number.outputs.nuGetVersion }}-1_${{ steps.get-arch.outputs.arch}}.deb
path: ./installers/deb/grate_${{ needs.set-version-number.outputs.nuGetVersion }}-1_${{ steps.get-arch.outputs.arch }}.deb

build-winget:
name: Winget - Update package manifest in the OWC
needs:
- set-version-number
- build-msi
runs-on: windows-latest
if: ${{ needs.set-version-number.outputs.is-release == 'true' }}
# build-winget:
# name: Winget - Update package manifest in the OWC
# needs:
# - set-version-number
# - build-msi
# runs-on: windows-latest
# if: ${{ needs.set-version-number.outputs.is-release == 'true' }}

steps:
- name: Winget-Create
run: |
# steps:
# - name: Winget-Create
# run: |

$version = "$($env:version)"
# $version = "$($env:version)"

# Download wingetcreate
iwr https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe
# # Download wingetcreate
# iwr https://aka.ms/wingetcreate/latest -OutFile wingetcreate.exe

$packageUrl="https://github.com/erikbra/grate/releases/download/$version/grate-$version.msi"
# $packageUrl="https://github.com/erikbra/grate/releases/download/$version/grate-$version.msi"

echo "Running ./wingetcreate.exe update erikbra.grate -u $packageUrl -v $version -t `"$env:WINGET_GH_PAT`" --submit"
./wingetcreate.exe update erikbra.grate -u $packageUrl -v $version -t "$env:WINGET_GH_PAT" --submit
env:
WINGET_GH_PAT: ${{ secrets.WINGET_GH_PAT }}
#version: "1.4.0"
version: "${{ needs.set-version-number.outputs.nuGetVersion }}"
# echo "Running ./wingetcreate.exe update erikbra.grate -u $packageUrl -v $version -t `"$env:WINGET_GH_PAT`" --submit"
# ./wingetcreate.exe update erikbra.grate -u $packageUrl -v $version -t "$env:WINGET_GH_PAT" --submit
# env:
# WINGET_GH_PAT: ${{ secrets.WINGET_GH_PAT }}
# #version: "1.4.0"
# version: "${{ needs.set-version-number.outputs.nuGetVersion }}"


test:
Expand All @@ -264,13 +261,12 @@ jobs:

steps:
- uses: actions/checkout@v3
- name: Setup .NET 6
uses: actions/setup-dotnet@v2
- name: Setup .NET 7
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
include-prerelease: false
dotnet-version: 7.0.x
- name: Test
run: dotnet test --filter FullyQualifiedName~grate.unittests.${{ matrix.category }} -c Release --logger:"trx;LogFilePath=test-results-${{ matrix.category }}.xml"
run: dotnet test --filter "FullyQualifiedName~grate.unittests.${{ matrix.category }}" -c Release --logger:"trx;LogFilePath=test-results-${{ matrix.category }}.xml" -- -MaxCpuCount 2
# run: dotnet test --verbosity Normal -c Release --logger "trx;LogFileName=/tmp/test-results/grate.unittests.trx"
env:
LogLevel: Warning
Expand Down
25 changes: 10 additions & 15 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup .NET 6
uses: actions/setup-dotnet@v2
- name: Setup .NET 7
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
include-prerelease: false
dotnet-version: 7.0.x
- name: Restore dependencies
run: dotnet restore -r linux-x64 grate.unittests/grate.unittests.csproj
- name: Build
Expand All @@ -52,17 +51,14 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v3

- name: Setup .NET 6
uses: actions/setup-dotnet@v2
- name: Setup .NET 7
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
include-prerelease: false
dotnet-version: 7.0.x

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
with:
languages: 'csharp'

- name: Autobuild
uses: github/codeql-action/autobuild@v2
Expand All @@ -86,13 +82,12 @@ jobs:
uses: actions/download-artifact@v3
with:
name: binaries
- name: Setup .NET 6
uses: actions/setup-dotnet@v2
- name: Setup .NET 7
uses: actions/setup-dotnet@v3
with:
dotnet-version: 6.0.x
include-prerelease: false
dotnet-version: 7.0.x
- name: Test
run: dotnet vstest --TestCaseFilter:"FullyQualifiedName~grate.unittests.${{ matrix.category }}" bin/grate.unittests.dll --logger:"trx;LogFileName=test-results-${{ matrix.category }}.xml"
run: dotnet test --filter "FullyQualifiedName~grate.unittests.${{ matrix.category }}" bin/grate.unittests.dll --logger:"trx;LogFileName=test-results-${{ matrix.category }}.xml" -- -MaxCpuCount 2
env:
LogLevel: Warning
TZ: UTC
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/grate-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
- uses: actions/checkout@v3

- name: Download grate
run: curl -sL https://github.com/erikbra/grate/releases/download/1.0.0/grate_1.0.0-1_amd64.deb -o /tmp/grate_1.0.0-1_amd64.deb
run: curl -sL https://github.com/erikbra/grate/releases/download/1.4.0/grate_1.4.0-1_amd64.deb -o /tmp/grate_1.4.0-1_amd64.deb

- name: Install grate
run: sudo dpkg -i /tmp/grate_1.0.0-1_amd64.deb
run: sudo dpkg -i /tmp/grate_1.4.0-1_amd64.deb

- name: Verify grate installation
run: grate --help
Expand All @@ -43,10 +43,10 @@ jobs:
- uses: actions/checkout@v3

- name: Download grate
run: curl -sL https://github.com/erikbra/grate/releases/download/1.0.0/grate_1.0.0-1_amd64.deb -o /tmp/grate_1.0.0-1_amd64.deb
run: curl -sL https://github.com/erikbra/grate/releases/download/1.4.0/grate_1.4.0-1_amd64.deb -o /tmp/grate_1.4.0-1_amd64.deb

- name: Install grate
run: sudo dpkg -i /tmp/grate_1.0.0-1_amd64.deb
run: sudo dpkg -i /tmp/grate_1.4.0-1_amd64.deb

- name: Verify grate installation
run: grate --help
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ git clone https://github.com/erikbra/grate.git

```
> cd grate
> dotnet test
> dotnet test --framework net7.0
```

## Build a self-contained executable (if you want)
Expand Down
23 changes: 14 additions & 9 deletions docs/ConfigurationOptions/FolderConfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ which might be a good starting point if you have no special requirements.
grate works with three different folder types:


| Folder/script type | Explanation | More info |
| ------ | ------- |------- |
| One-time scripts | These are scripts that are run **exactly once** per database, and never again. | [One time scripts](../ScriptTypes/OneTimeScripts.md#one-time-scripts) |
| Anytime Scripts | These scripts are run **any time they're changed** | [Anytime scripts](../ScriptTypes/AnytimeScripts.md#anytime-scripts) |
| Everytime Scripts | These scripts are run (you guessed it) **every time** grate executes :) | [Everytime scripts](../ScriptTypes/EverytimeScripts.md#everytime-scripts) |
| Folder/script type | Name | Explanation | More info |
| ------ |----| ------- |------- |
| One-time scripts | Once | These are scripts that are run **exactly once** per database, and never again. | [One time scripts](../ScriptTypes/OneTimeScripts.md#one-time-scripts) |
| Anytime Scripts | AnyTime | These scripts are run **any time they're changed** | [Anytime scripts](../ScriptTypes/AnytimeScripts.md#anytime-scripts) |
| Everytime Scripts | EveryTime | These scripts are run (you guessed it) **every time** grate executes :) | [Everytime scripts](../ScriptTypes/EverytimeScripts.md#everytime-scripts) |

## Specifying a custom folder configuration

Expand All @@ -44,9 +44,12 @@ This would use the [default folder configuration](#default-folder-configuration)
`ddl` folder for **up** scripts, in the `projections` folder for **views**, and in the `preparefordeploy` folder for **beforemigration** scripts.

```
--folders up=ddl;views=projections;beforemigration=preparefordeploy
--folders 'up=ddl;views=projections;beforemigration=preparefordeploy'
```

**NOTE:** Be sure to use quotes when specifying multiple folders in the argument, as many shells treat `;` as
a the "end this command" character, so everything after the `;` will not be part of the command line.

or

```
Expand Down Expand Up @@ -81,7 +84,7 @@ The properties you can set per folder, are:
| ------ | ------- | ------- | ------- |
| Name | the key/name you wish to give to the folder | (doesn't matter if path is specified) | _(none)_ |
| Path | the relative path of the folder, relative to the --sqlfilesdirectory parameter. | Any relative path | the **Name** specified above.
| Type | the type of the migration | Once, EveryTime, Anytime | Once |
| Type | the type of the migration | Once, EveryTime, AnyTime | Once |
| ConnectionType | whether to run on the default connection, or on the admin | Default, Admin | Default |
| TransactionHandling | whether to be part of the transaction (if running the migration in a transaction), or run the script in an autonomous transaction, so that it is always run, even on a rollback | Default, Autonomous | Default |

Expand All @@ -96,7 +99,7 @@ Example:
or

```
--folders folder1=Once;folder2=Everytime;folder3=Anytime
--folders folder1=Once;folder2=EveryTime;folder3=AnyTime
```

the last one will expect the folders to be named `folder1`, `folder2`, and `folder3`,
Expand All @@ -116,7 +119,7 @@ folders, should you wish so.
Simply specify the folders you want to override in the `--folders` parameter. The ones you don't mention, will remain configured
as default.

An example, if you want to use a folder `tables` to keeep you `up` scripts in, use the following argument to grate:
An example, if you want to use a folder `tables` to keep you `up` scripts in, use the following argument to grate:

```bash
$ grate --folders up=tables
Expand All @@ -128,6 +131,8 @@ grate processes the files in a standard set of directories in a fixed order for

| Folder | Script type | Explanation |
| ------ | ------- |------- |
| <nobr> (-1. dropDatabase)</nobr> | Anytime scripts | If you have the need for a custom `DROP DATABASE` script (used with the `--drop` command-line flag) |
| <nobr> (0. createDatabase)</nobr> | Anytime scripts | If you have the need for a custom `CREATE DATABASE` script, put it here, and it will be used instead of the default. |
| <nobr> 1. beforeMigration</nobr> | Everytime scripts | If you have particular tasks you want to perform prior to any database migrations (custom logging? database backups? disable replication?) you can do it here. |
| <nobr>2. alterDatabase</nobr> | Anytime scripts | If you have scripts that need to alter the database config itself (rather than the _contents_ of the database) thjis is the place to do it. For example setting recovery modes, enabling query stores, etc etc |
| <nobr>3. runAfterCreateDatabase</nobr> | Anytime scripts | This directory is only processed if the database was created from scratch by grate. Maybe you need to add user accounts or similar?
Expand Down
2 changes: 1 addition & 1 deletion docs/ConfigurationOptions/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ grate --connectionstring="Server=(localdb)\MSSQLLocalDB;Integrated Security=true
| Option | Default | Purpose |
| ------ | ------- | ------- |
| -c<br>-cs<br>--connectionstring<br>--connstring &lt;connectionstring&gt; | - | **REQUIRED** You now provide an entire connection string. ServerName and Database are obsolete. |
| -a<br>-acs<br>-csa<br>--adminconnectionstring<br>--adminconnstring &lt;adminconnectionstring&gt; | Same as --connectionstring | The connection string for connecting to master, if you want to create the database. |
| -a<br>-acs<br>-csa<br>--adminconnectionstring<br>--adminconnstring &lt;adminconnectionstring&gt; | The value provided via --connectionstring, with the target database replaced with a database that can be assumed to be present. For example, "master" for SQL Server. | Used when creating a new database, rather than migrating an existing one. |
| -f<br>--files<br>--sqlfilesdirectory &lt;sqlfilesdirectory&gt; | . (current directory) | The directory where your SQL scripts are located |
| --folders | Default folders as described in [Getting started](../GettingStarted.md) | Folder configuration, see [Folder configuration](FolderConfiguration.md) for details. |
| -o<br>--output<br>--outputPath &lt;outputPath&gt; | %LOCALAPPDATA%/grate | This is where everything related to the migration is stored. This includes any backups, all items that ran, permission dumps, logs, etc. |
Expand Down
4 changes: 4 additions & 0 deletions docs/GettingGrate.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ please install [dotnet 6](https://dotnet.microsoft.com/download/dotnet/6.0)

grate is available on [winget](https://docs.microsoft.com/en-us/windows/package-manager/winget/). Simply `winget install erikbra.grate` for awesome!

## Homebrew

grate is available as a Homebrew cask. Simply `brew install --cask erikbra/cask/grate` for awesomeness!

## Notes

Plans are afoot for more OS specific package managers, watch this space.
Loading

0 comments on commit 53b3eb5

Please sign in to comment.