Compare commits
32 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b468049cfb | |||
| c81d631cf0 | |||
| 137ebdece2 | |||
| bbc52c8cd1 | |||
| f3497dbff3 | |||
| 02ce1fdf01 | |||
| 005be96d2b | |||
| 26f673f4e9 | |||
| 96caf54474 | |||
| 088f13d9a1 | |||
| d6414c9219 | |||
| 9aff600d75 | |||
| 0b9d03dffb | |||
| 24a40126de | |||
| 662d44c137 | |||
| d8c592bb70 | |||
| 81c1bf9dc0 | |||
| 7d15179fc8 | |||
| 17141b7e76 | |||
| ae847b96d7 | |||
| 55d3c84cf3 | |||
| 1b965e293f | |||
| 9318e734a5 | |||
| 74bf1abad8 | |||
| bac2c74190 | |||
| 3f0383a7b2 | |||
| 90af924221 | |||
| 49eca1605a | |||
| 9a894998bf | |||
| cf1f4dcde3 | |||
| 28bba63131 | |||
| c7cd22c343 |
Vendored
+73
@@ -0,0 +1,73 @@
|
||||
pipeline {
|
||||
agent {
|
||||
docker {
|
||||
image 'hub.davinti.com.br:443/infra/node:latest'
|
||||
args '-u 1001:1001 --rm --entrypoint="" -e HOME=${WORKSPACE}'
|
||||
}
|
||||
}
|
||||
|
||||
environment {
|
||||
S3_BUCKET = "s3://app-dono-manifests"
|
||||
GIT_TOKEN = credentials('gitea-pat')
|
||||
}
|
||||
|
||||
stages {
|
||||
stage('Install') {
|
||||
|
||||
steps {
|
||||
sh """
|
||||
# Create a .netrc file so Git can find the PAT for your Gitea domain
|
||||
echo "machine git.davinti.com.br" > ~/.netrc
|
||||
echo "login jenkins" >> ~/.netrc
|
||||
echo "password ${GIT_TOKEN}" >> ~/.netrc
|
||||
chmod 600 ~/.netrc
|
||||
|
||||
npm install
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
stage('Vet') {
|
||||
steps {
|
||||
echo 'Validating modules (Standard for all branches)...'
|
||||
sh 'npx jeff vet -i "src/**/*.module.ts" --strict'
|
||||
}
|
||||
}
|
||||
|
||||
stage('Generate & Upload') {
|
||||
when {
|
||||
branch 'main'
|
||||
}
|
||||
steps {
|
||||
echo 'Generating manifest and deploying to S3...'
|
||||
sh 'npm run generate:output'
|
||||
|
||||
sh 'tar -czvf migrations.tar.gz -C migrations/ .'
|
||||
|
||||
withAWS(credentials: 'aws-jeff-credentials-id', region: 'sa-east-1') {
|
||||
script {
|
||||
echo "Uploading to S3..."
|
||||
sh "aws s3 cp dist/manifest.json ${S3_BUCKET}/manifest.json"
|
||||
sh "aws s3 cp migrations.tar.gz ${S3_BUCKET}/migrations.tar.gz"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
post {
|
||||
always {
|
||||
sh 'rm -rf *'
|
||||
script {
|
||||
deleteDir()
|
||||
}
|
||||
}
|
||||
success {
|
||||
echo "✨ Manifest successfully uploaded to S3!"
|
||||
}
|
||||
failure {
|
||||
echo "❌ Build failed. Check the logs for Jeff's validation errors."
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
# Migrations
|
||||
|
||||
Este projeto utiliza [pressly/goose](https://github.com/pressly/goose) para
|
||||
gerenciamento de migrações de banco de dados. Cada ERP possui seu próprio set de
|
||||
migrations. Por exemplo, `migrations/C5/*.sql`, `migrations/SENIOR/*.sql`...
|
||||
|
||||
## Instalação
|
||||
|
||||
```bash
|
||||
go install github.com/pressly/goose/v3/cmd/goose@latest
|
||||
```
|
||||
|
||||
## Criando uma migração
|
||||
|
||||
```bash
|
||||
goose -dir migrations/<ERP> create nome_da_migracao sql
|
||||
```
|
||||
|
||||
Isso gera um arquivo com timestamp no formato
|
||||
`YYYYMMDDHHMMSS_nome_da_migracao.sql` contendo seções `-- +goose Up` e `--
|
||||
+goose Down`.
|
||||
|
||||
## Boas práticas
|
||||
|
||||
- **Sempre escreva a migração `Down`**: garante que a migração possa ser
|
||||
revertida com segurança.
|
||||
- **Uma mudança por migração**: mantenha cada arquivo focado em uma única
|
||||
alteração (criar tabela, adicionar coluna, etc.).
|
||||
- **Migrações devem ser idempotentes quando possível**: use `IF NOT EXISTS` /
|
||||
`IF EXISTS` para evitar falhas em re-execução.
|
||||
- **Nunca altere uma migração já aplicada**: se algo precisa ser corrigido, crie
|
||||
uma nova migração.
|
||||
- **Evite migrações destrutivas em produção**: prefira adicionar colunas
|
||||
nullable e remover as antigas em uma migração posterior, em vez de renomear ou
|
||||
deletar diretamente.
|
||||
- **Teste localmente antes de aplicar**: rode `up` e `down` no ambiente local
|
||||
para verificar que ambas as direções funcionam.
|
||||
Generated
+3
-3
@@ -9,15 +9,15 @@
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@davinti/jeff": "git+https://git.davinti.com.br/davinTI/jeff.git#v1.0.5"
|
||||
"@davinti/jeff": "git+https://git.davinti.com.br/davinTI/jeff.git#v1.0.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tsx": "^4.21.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@davinti/jeff": {
|
||||
"version": "1.0.5",
|
||||
"resolved": "git+https://git.davinti.com.br/davinTI/jeff.git#de72040736f1459809722c87d602185ae470fb76",
|
||||
"version": "1.0.8",
|
||||
"resolved": "git+https://git.davinti.com.br/davinTI/jeff.git#aa32d9bc6e5ab4b6a4c5f2748fa68e4bfdd2b4e2",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@types/glob": "^8.1.0",
|
||||
|
||||
+1
-1
@@ -12,7 +12,7 @@
|
||||
"license": "ISC",
|
||||
"description": "",
|
||||
"dependencies": {
|
||||
"@davinti/jeff": "git+https://git.davinti.com.br/davinTI/jeff.git#v1.0.5"
|
||||
"@davinti/jeff": "git+https://git.davinti.com.br/davinTI/jeff.git#v1.0.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tsx": "^4.21.0"
|
||||
|
||||
@@ -99,6 +99,7 @@ inner join mboard.tb_empresa_segmento tes
|
||||
where 1=1
|
||||
and tvf.vlrvendaacumulada > 0
|
||||
and tvf.dtavda = TO_DATE(${args.data_venda}, 'YYYY-MM-DD')
|
||||
and (tvf.nroempresa in (${args.ctx_user_companies_for_module}))
|
||||
group by rollup(canalapp, nomeempresaapp)
|
||||
order by grouping(canalapp) desc, grouping(nomeempresaapp) desc`,
|
||||
};
|
||||
|
||||
+1353
-34
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user