Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2025-02-04-add_vl_pipe_section_pipe_dn #85

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

sjib
Copy link
Contributor

@sjib sjib commented Feb 4, 2025

Should solve #53

@sjib sjib added enhancement New feature or request datamodel labels Feb 4, 2025
@sjib
Copy link
Contributor Author

sjib commented Feb 4, 2025

psql:/src/datamodel/scripts/../changelogs/0001/05_add_vl_pipe_section_pipe_dn.sql:43: ERROR:  foreign key constraint "fkey_vl_pipe_section_pipe_dn" cannot be implemented
DETAIL:  Key columns "nominal_diameter" and "code" are of incompatible types: text and integer.

@sjib
Copy link
Contributor Author

sjib commented Feb 4, 2025

Nominal_diameter is defined as text
ALTER TABLE tdh_od.pipe_section ADD COLUMN nominal_diameter text;

So we need to modify that.

@sjib
Copy link
Contributor Author

sjib commented Feb 4, 2025

Change type of column -- see https://stackoverflow.com/questions/7162903/how-to-alter-a-columns-data-type-in-a-postgresql-table (version that allows to have already data in db)

@sjib
Copy link
Contributor Author

sjib commented Feb 4, 2025

2025-02-04 16:43:24.285 UTC [110] ERROR:  function char_length(integer) does not exist
2025-02-04 16:43:24.285 UTC [110] HINT:  No function matches the given name and argument types. You might need to add explicit type casts.
2025-02-04 16:43:24.285 UTC [110] STATEMENT:  ALTER TABLE tdh_od.pipe_section ALTER COLUMN nominal_diameter TYPE integer USING (NULLIF(nominal_diameter, '')::integer);

@sjib
Copy link
Contributor Author

sjib commented Feb 4, 2025

@ponceta Any idea how to change column type from text to integer in a more "safe" way? Do we need to consider to keep existing data?

@sjib
Copy link
Contributor Author

sjib commented Feb 4, 2025

Maybe more idea to deal with that issue: https://stackoverflow.com/questions/10518258/typecast-string-to-integer

ALTER TABLE tdh_od.pipe_section
DROP COLUMN IF EXISTS nominal_diameter;

ALTER TABLE tdh_od.pipe_section ADD COLUMN nominal_diameter integer;
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
ALTER TABLE tdh_od.pipe_section ADD COLUMN nominal_diameter integer;
ALTER TABLE tdh_od.pipe_section ADD COLUMN material integer;

/* AJOUT DE LA TABLE DES DIAMETRES NOMINAUX DE CONDUITES () */
/*---------------------------------------------------------------------------------------*/

CREATE TABLE tdh_vl.pipe_section_pipe_dn () INHERITS (tdh_vl.value_list_base);
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
CREATE TABLE tdh_vl.pipe_section_pipe_dn () INHERITS (tdh_vl.value_list_base);
CREATE TABLE tdh_vl.pipe material () INHERITS (tdh_vl.value_list_base);

@@ -34,6 +34,8 @@ psql "service=${PGSERVICE}" -v ON_ERROR_STOP=1 -f ${DIR}/changelogs/0001/04_tdh_

# psql "service=${PGSERVICE}" -v ON_ERROR_STOP=1 -f ${DIR}/changelogs/0001/05_data_model_extensions.sql

psql "service=${PGSERVICE}" -v ON_ERROR_STOP=1 -f ${DIR}/changelogs/0001/05_add_vl_pipe_section_pipe_dn.sql
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
psql "service=${PGSERVICE}" -v ON_ERROR_STOP=1 -f ${DIR}/changelogs/0001/05_add_vl_pipe_section_pipe_dn.sql
psql "service=${PGSERVICE}" -v ON_ERROR_STOP=1 -f ${DIR}/changelogs/0001/05_add_vl_pipe_material.sql

@ponceta
Copy link
Member

ponceta commented Feb 5, 2025

👍 on removing nominal diameter from table pipe_section

Change requested : name the material table tdh_vl.material and the corresponding foreign key pipe_section.material

@ponceta
Copy link
Member

ponceta commented Feb 5, 2025

We had a similar case fixed by @rbovard on qwat/qwat-data-model@a44e1a0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
datamodel enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants