Skip to content

Adiciona exsicata_tipo - #156

Closed
vitorRibeiro7 wants to merge 12 commits into
developmentfrom
149-adicionar-os-campos-unicata-ou-duplicata-na-tabela-tombo
Closed

vitorRibeiro7 wants to merge 12 commits into
developmentfrom
149-adicionar-os-campos-unicata-ou-duplicata-na-tabela-tombo

Conversation

@vitorRibeiro7

Copy link
Copy Markdown
Contributor

Adicionado a criação do campo exsicata_tipo na tabela tombos, inserido o fluxo dentro da migration.
Processa um csv para os tombos do firebird que contem as substrings "unicata" ou "duplicata" no campo [obs_tombo].

Inclui também o novo campo nas rotas de criação e edição do tombo.

@vitorRibeiro7 vitorRibeiro7 linked an issue Aug 19, 2025 that may be closed by this pull request

export async function run(knex: Knex): Promise<void> {
await knex.transaction(async trx => {
await trx.raw(`

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A mudança na estrutura não precisa estar dentro de uma transação, não faz diferença.


export async function run(knex: Knex): Promise<void> {
await knex.transaction(async trx => {
await trx.raw(`

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Utiliza o esquema de migração já existe no Knex, por favor. Vai facilitar quando a gente for mudar de MySQL para Postgres.

https://knexjs.org/guide/schema-builder.html#withschema

ADD COLUMN exsicata_tipo ENUM('UNICATA', 'DUPLICATA') NULL;
`)

const rows = parseFile(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Duas coisas aqui.

  • Acho que não me fiz entender no dia. Cria o diretório com o .csv dentro do diretório migration e não fora.
  • Quando for ler o arquivo, utiliza o caminho relativo ao arquivo atual utilizando o path node Node, por exemplo path.join(__dirname, 'caminho-arquivo.csv')

for await (const row of rows) {
const { id, tombo_tipo: tomboTipo } = row

if (!tomboTipo) return

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Se um tombo não tem valor em tombo_tipo, ele deveria estar no CSV?

await knex.transaction(async trx => {
await trx.raw(`
ALTER TABLE tombos
ADD COLUMN exsicata_tipo ENUM('UNICATA', 'DUPLICATA') NULL;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Por que mudamos de true/false para um ENUM? Embora hoje possa existir o null, ele deveria ser um valor lógico sim ou não. Criar um ENUM não me parece fazer sentido nesse caso, pois não teremos mais de dois valores no futuro.

Comment thread src/validators/tombo-alteracao.js Outdated
options: [{ min: 3 }],
},
},
'json.exsicataTipo': {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Utilize underline para manter o padrão do projeto.

Comment thread src/validators/tombo-cadastro.js Outdated
options: [{ min: 3 }],
},
},
'json.exsicataTipo': {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Utilize underline para manter o padrão do projeto.

@vitorRibeiro7 vitorRibeiro7 changed the title Adiciona esicatra_tipo Adiciona exsicata_tipo Aug 22, 2025
@vitorRibeiro7
vitorRibeiro7 deleted the 149-adicionar-os-campos-unicata-ou-duplicata-na-tabela-tombo branch August 27, 2025 15:56
@vitorRibeiro7
vitorRibeiro7 restored the 149-adicionar-os-campos-unicata-ou-duplicata-na-tabela-tombo branch August 29, 2025 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants