Re: Enforce primary key on every table during dev?

2018-03-01 Thread bto...@computer.org
- Original Message -
> From: "Tim Cross" 
> Sent: Wednesday, February 28, 2018 4:07:43 PM
> 
> Jeremy Finzel  writes:
> 
> > We want to enforce a policy, partly just to protect those who might forget,
> > for every table in a particular schema to have a primary key.  This can't
> > be done with event triggers as far as I can see, because it is quite
> > legitimate to do:
> >
> > BEGIN;
> > CREATE TABLE foo (id int);
> > ALTER TABLE foo ADD PRIMARY KEY (id);
> > COMMIT;
> >
> > It would be nice to have some kind of "deferrable event trigger" or some
> > way to enforce that no transaction commits which added a table without a
> > primary key.
> >
> 
> I think you would be better off having an automated report which alerts
> you to tables lacking a primary key and deal with that policy through
> other means. Using triggers in this way often leads to unexpected
> behaviour and difficult to identify bugs. The policy is a management
> policy and probably should be dealt with via management channels rather
> than technical ones. Besides, the likely outcome will be your developers
> will just adopt the practice of adding a serial column to every table,
> which in itself doesn't really add any value.

I concur with other respondents that suggest this is more of a policy issue. In 
fact, you yourself identify it right there in the first sentence as a policy 
issue! 

One tool that changed my life (as a PostgreSQL enthusiast) forever is David 
Wheeler's pgTAP (http://pgtap.org/) tool. It includes a suite of functionality 
to assess the database schema via automated testing. Part of a rigorous 
development environment might include using this tool so that any 
application/database changes be driven by tests, and then your code review 
process would assure that the appropriate tests are added to the pgTAP script 
to confirm that changes meet a policy standard such as what you are demanding. 
I can't imagine doing PostgreSQL development without it now.

Same guy also produced a related tool called Sqitch (http://sqitch.org/) for 
data base change management. Use these tools together, so that before a 
developer is allowed to check in a feature branch, your teams' code review 
process maintains rigorous oversight of modifications.

-- B




What does Natvie Posgres mean?

2018-06-12 Thread bto...@computer.org


When someone, e.g., as appeared in a recent and some older pgsql-jobs messages, 
says "Native Postgres", what do you suppose that means? 

Does it mean something different than just "PostgreSQL"?

Is the word "Native" just noise, or does it actually refer to something 
specific?

A quick google search reveals that there apparently is a thing called 
"postgres-native" which is described as "...a native D implementation of the 
Postgres frontend/backend protocol.", but I don't get the sense that this is 
what is being talked about.

-- B







Re: Alter view with dependence without drop view!

2018-01-30 Thread bto...@computer.org
One way I have approached this problem is: 

1) Use PgAdmin attempt the change. 

2) Examine the error report PgAdmin displays that identifies which dependent 
views are preventing your progress. 

3) Wrap your original DDL from step 1 within the DROP and CREATE DDL associated 
with the closest dependent view. 

4) Return to step 1 and repeat until step 1 succeeds. 

With multiple iterations of this procedure, you will incrementally grow a DDL 
script that drops dependent views in the correct order, eliminating 
dependencies, and then recreate them in the proper order, respecting 
dependencies. 



When this procedure got old, I started using a script created using pg_dump and 
pg_restore, as initially outlined here: 

https://www.postgresql.org/message-id/55c3f0b4.5010...@computer.org 

and with a correction noted here: 

https://www.postgresql.org/message-id/0456dfda-4623-1331-7dca-e3cff914357b%40computer.org
 




-- B 


- Original Message -


From: "Elson Vaz"  
To: pgsql-general@lists.postgresql.org 
Sent: Tuesday, January 30, 2018 8:40:45 AM 
Subject: Alter view with dependence without drop view! 

Hello! 

I want make change in one view that have dependence view's, so when i try to 
make change i'm block because of this, what is the best solution?? 

thank you!! 

best regard 

Elson Vaz