Add migration check script
This commit is contained in:
parent
6e19098dee
commit
75c9374420
|
@ -3,13 +3,6 @@ _extends: probot-settings
|
||||||
github-team:
|
github-team:
|
||||||
slug: 'go'
|
slug: 'go'
|
||||||
|
|
||||||
prchecklist:
|
|
||||||
title: Pull Request Checklist
|
|
||||||
checklist:
|
|
||||||
- 'Have you updated the documentation, if impacted (e.g. [docs.status.im](https://status.im/docs/))?'
|
|
||||||
- 'Have you tested changes with mobile?'
|
|
||||||
- 'Have you tested changes with desktop?'
|
|
||||||
|
|
||||||
stale:
|
stale:
|
||||||
daysUntilStale: 90
|
daysUntilStale: 90
|
||||||
daysUntilPullRequestStale: 14
|
daysUntilPullRequestStale: 14
|
||||||
|
|
7
Makefile
7
Makefile
|
@ -388,6 +388,13 @@ migration: DEFAULT_MIGRATION_PATH := appdatabase/migrations/sql
|
||||||
migration:
|
migration:
|
||||||
touch $(DEFAULT_MIGRATION_PATH)/$(shell date +%s)_$(D).up.sql
|
touch $(DEFAULT_MIGRATION_PATH)/$(shell date +%s)_$(D).up.sql
|
||||||
|
|
||||||
|
migration-check:
|
||||||
|
bash _assets/scripts/migration_check.sh
|
||||||
|
|
||||||
|
install-git-hooks:
|
||||||
|
@ln -s -f $(shell pwd)/_assets/hooks/pre-rebase .git/hooks
|
||||||
|
@ln -s -f $(shell pwd)/_assets/hooks/pre-merge-commit .git/hooks
|
||||||
|
|
||||||
migration-protocol: DEFAULT_PROTOCOL_PATH := protocol/migrations/sqlite
|
migration-protocol: DEFAULT_PROTOCOL_PATH := protocol/migrations/sqlite
|
||||||
migration-protocol:
|
migration-protocol:
|
||||||
touch $(DEFAULT_PROTOCOL_PATH)/$(shell date +%s)_$(D).up.sql
|
touch $(DEFAULT_PROTOCOL_PATH)/$(shell date +%s)_$(D).up.sql
|
||||||
|
|
|
@ -49,6 +49,11 @@ pipeline {
|
||||||
} }
|
} }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stage('Migration') {
|
||||||
|
steps { script {
|
||||||
|
nix.shell('make migration-check')
|
||||||
|
} }
|
||||||
|
}
|
||||||
|
|
||||||
stage('Lint') {
|
stage('Lint') {
|
||||||
steps { script {
|
steps { script {
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
make migration-check
|
|
@ -0,0 +1,3 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
make migration-check
|
|
@ -0,0 +1,29 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
check_migration_order() {
|
||||||
|
local prev_migration=""
|
||||||
|
for file in "$@"; do
|
||||||
|
current_migration=$(echo "$file" | cut -d'-' -f1)
|
||||||
|
|
||||||
|
if [[ ! -z "$prev_migration" && "$current_migration" < "$prev_migration" ]]; then
|
||||||
|
|
||||||
|
echo "migration ${current_migration} is not in order with ${prev_migration}"
|
||||||
|
echo "Error: Migration files are out of order. Please ensure migrations are added in chronological order."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
prev_migration="$current_migration"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
committed_files=$(git ls-tree -r --name-only HEAD protocol/migrations/sqlite/*.sql | sort)
|
||||||
|
staged_files=$(git diff --name-only origin/develop protocol/migrations/sqlite/*.sql | sort)
|
||||||
|
|
||||||
|
all_files=$(echo -e "$committed_files\n$staged_files")
|
||||||
|
|
||||||
|
check_migration_order $all_files
|
||||||
|
|
||||||
|
exit 0
|
Loading…
Reference in New Issue