Thread: databse version

databse version

From
Philipp Kraus
Date:
Hello,

I'm creating a database and I have got a table with a "version" field.
Can I update on structure changes (DDL) like create / update table
increment this field automatically?
I would like to create a versionizing for my database which counts the changes.
IMHO I need a trigger, which is run if a DDL statement is fired on the database

Thanks

Phil


Re: databse version

From
Adrian Klaver
Date:
On 06/10/2013 12:52 AM, Philipp Kraus wrote:
> Hello,
>
> I'm creating a database and I have got a table with a "version" field.
> Can I update on structure changes (DDL) like create / update table
> increment this field automatically?
> I would like to create a versionizing for my database which counts the
> changes.
> IMHO I need a trigger, which is run if a DDL statement is fired on the
> database

In the current beta 9.3 there are event triggers that would seem to be
what you are looking for:

http://www.postgresql.org/docs/9.3/static/event-triggers.html


>
> Thanks
>
> Phil
>
>
>
>


--
Adrian Klaver
adrian.klaver@gmail.com


Re: databse version

From
John R Pierce
Date:
On 6/10/2013 12:52 AM, Philipp Kraus wrote:
> I'm creating a database and I have got a table with a "version" field.
> Can I update on structure changes (DDL) like create / update table
> increment this field automatically?
> I would like to create a versionizing for my database which counts the
> changes.
> IMHO I need a trigger, which is run if a DDL statement is fired on the
> database

so if someone runs a script that does a half dozen create/alters, you
want to bump your version that many times?

we handle our version control by not allowing anyone to make direct
changes, instead all changes need to be made with .sql scripts, of which
we maintain two sets, one to create a new schema version x.y, and the
other to update x.y-1 to x.y.   and yes, part of these scripts stores
the version in a configuration table of (key,value) pairs, like
('version','x.y')



--
john r pierce                                      37N 122W
somewhere on the middle of the left coast



Re: databse version

From
Scott Marlowe
Date:

Re: databse version

From
Luca Ferrari
Date:
On Mon, Jun 10, 2013 at 9:52 AM, Philipp Kraus
<philipp.kraus@flashpixx.de> wrote:
> Hello,
>
> I'm creating a database and I have got a table with a "version" field.

Not sure, but if the version field is something like the version row
indicator used by some frameworks (e.g., Hibernate), then you are
going to place the updated version into all your records, that does
not sound as versioning at all!

Luca


Re: databse version

From
Philipp Kraus
Date:
On 2013-06-11 00:42:59 +0200, John R Pierce said:

> On 6/10/2013 12:52 AM, Philipp Kraus wrote:
>> I'm creating a database and I have got a table with a "version" field.
>> Can I update on structure changes (DDL) like create / update table
>> increment this field automatically?
>> I would like to create a versionizing for my database which counts the changes.
>> IMHO I need a trigger, which is run if a DDL statement is fired on the database
>
> so if someone runs a script that does a half dozen create/alters, you
> want to bump your version that many times?
>
> we handle our version control by not allowing anyone to make direct
> changes, instead all changes need to be made with .sql scripts, of
> which we maintain two sets, one to create a new schema version x.y, and
> the other to update x.y-1 to x.y.   and yes, part of these scripts
> stores the version in a configuration table of (key,value) pairs, like
> ('version','x.y')

You're right. The database versionizing seems to be a problem, but I
would like run a automatism for versionizing eg the commit hash on git.
I have got a SQL script with the create calls
(alter will be create in the future). So our buildsystem get the head
of the git repo and builds the application, the database sql script is
also stored in the repo. In my case I would dump the database on the
developer server, check if the repo script and the dump script are
equal and if not, I increment the version number in dem dump script and
push it into the repo.

On the release process the version counting is depend on the prior
release. I think about a number like <release>.<subrelease>.<changes>

Phil