You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@subversion.apache.org by Basile STARYNKEVITCH <ba...@starynkevitch.net> on 2005/02/27 17:03:53 UTC

versioning a [small] MySQL database with svn?

Dear All,


The documentation mentions start-commit & pre-commit hooks etc...
See http://svnbook.red-bean.com/en/1.1/ch05s02.html#svn-ch-5-sect-2.1

It seems to me that these hooks could be used to version a
database. For instance, suppose that my SVN-managed project Foo
contains not only files like Foo/main.c and Foo/foo.h but also a small
MySQL database foo_db

Then I would want to manage a Foo/foo_db.sql file, provided that
before each commit the SubVersion system runs the command
   mysqldump foo_db > foo_db.sql
inside the versioned working copy 

It seems to me that having this command inside my start-commit script
is not enough. (and I would like to manage the script thru SVN and
have it automagically installed as a hook).

I believe that this is a common scenario that one want to version a
file produced by a command (be it a RDBMS dump, or an HTTP client like
wget, or a GDBM dump...) and to ensure that the SubVersion system
produces this file (by running this command) before commits.

I'm a bit surprised that such a scenario is not explicitly appearing
in the documentation. Either I misunderstood something (most probably)
or maybe something is lacking in the documentation or the SVN
software.

Any clues or insight please?

Thanks for reading. Regards.

-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/ 
email: basile<at>starynkevitch<dot>net 
aliases: basile<at>tunes<dot>org = bstarynk<at>nerim<dot>net
8, rue de la Faïencerie, 92340 Bourg La Reine, France

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: versioning a [small] MySQL database with svn?

Posted by Ed MacDonald <ed...@hotmail.com>.
From: "Basile STARYNKEVITCH" <ba...@starynkevitch.net>
Subject: Re: versioning a [small] MySQL database with svn?


> > Are you talking about dumping just the schema or the data as well?
Every
> > application I've been involved with required some "seed" data.  In your
> > scenario you either have to manage seed data separately from the schema,
or
> > end up checking in test/development data along with your schema thus
> > polluting your seed data.
>
> I dump the entire MySQL database. As I said before, this database is
> small. Currently, the mysqldump output size is a dozen kilobytes, and
> it won't grow past a megabyte or two (which is a manageable size);
> running the mysqldump command is very quick.
>


What I was getting at here is not about time or size but rather being able
to produce a "clean" system.  Consider an order entry system.  Through the
course of development and testing you would typically be creating orders.
When you deliver the system you want the order table *without* data and the
country/province table *with* data.  If however your app uses data but
doesn't produce data (e.g a dictionary) then this might not be a concern.

Ed

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: versioning a [small] MySQL database with svn?

Posted by Basile STARYNKEVITCH <ba...@starynkevitch.net>.
Le Sun, Feb 27, 2005 at 11:03:15AM -0700, Ed MacDonald écrivait/wrote:
> Hook scripts are a server-side and working copies are client-side so a hook
> script can't run "inside the working copy".  If you really want to do this,
> you would need to wrap the svn client.  There has been talk of client-side
> hooks on this list before but I can't recall what the consensus was.
> 
> In your scenario, every time I commit any file, you would dump the database
> and try to commit it too just in case it has changed.  It seems to me that
> this would needlessly slow down the development process.

Not in my case. Running the mysqldump command is a small fraction of a
second. I'm very far from having the mysqldump time be
annoying.... The current mysqldump time is about 0.01s (ten
milliseconds of real time) but 5 seconds would be acceptable and is
five hundred times bigger!

Actually I am experimenting with a sort of rule-based bootstrapped
language implementation, and my system is made of a small MySQL
database with a set of C source files (mostly generated by my system
itself). I want to version control my entire system, this means both
the MySQL database and the (mostly generated) C files. Of course, I
don't backup compiled binary files (ie .o and .so files and the main
program).

> 
> Are you talking about dumping just the schema or the data as well?  Every
> application I've been involved with required some "seed" data.  In your
> scenario you either have to manage seed data separately from the schema, or
> end up checking in test/development data along with your schema thus
> polluting your seed data.

I dump the entire MySQL database. As I said before, this database is
small. Currently, the mysqldump output size is a dozen kilobytes, and
it won't grow past a megabyte or two (which is a manageable size);
running the mysqldump command is very quick.

> 
> Here is what works for me.  I use three files for the DB (Schema.sql,
> SeedData.sql, TestData.sql).  Then every night during the build the DB gets
> dumped/dropped/recreated before unit tests are run.  The dump is a temporary
> file just in case someone forgot to update the DB files in source
> control.

A big thanks for your suggestion.

I'll probably wrapup the svn commit command in my own script (which
will call mysqldump before).

Regards.

-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/ 
email: basile<at>starynkevitch<dot>net 
aliases: basile<at>tunes<dot>org = bstarynk<at>nerim<dot>net
8, rue de la Faïencerie, 92340 Bourg La Reine, France

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: versioning a [small] MySQL database with svn?

Posted by Ed MacDonald <ed...@hotmail.com>.
Hook scripts are a server-side and working copies are client-side so a hook
script can't run "inside the working copy".  If you really want to do this,
you would need to wrap the svn client.  There has been talk of client-side
hooks on this list before but I can't recall what the consensus was.

In your scenario, every time I commit any file, you would dump the database
and try to commit it too just in case it has changed.  It seems to me that
this would needlessly slow down the development process.

Are you talking about dumping just the schema or the data as well?  Every
application I've been involved with required some "seed" data.  In your
scenario you either have to manage seed data separately from the schema, or
end up checking in test/development data along with your schema thus
polluting your seed data.

Here is what works for me.  I use three files for the DB (Schema.sql,
SeedData.sql, TestData.sql).  Then every night during the build the DB gets
dumped/dropped/recreated before unit tests are run.  The dump is a temporary
file just in case someone forgot to update the DB files in source control.

Hope this helps,

Ed





>
> Dear All,
>
>
> The documentation mentions start-commit & pre-commit hooks etc...
> See http://svnbook.red-bean.com/en/1.1/ch05s02.html#svn-ch-5-sect-2.1
>
> It seems to me that these hooks could be used to version a
> database. For instance, suppose that my SVN-managed project Foo
> contains not only files like Foo/main.c and Foo/foo.h but also a small
> MySQL database foo_db
>
> Then I would want to manage a Foo/foo_db.sql file, provided that
> before each commit the SubVersion system runs the command
>    mysqldump foo_db > foo_db.sql
> inside the versioned working copy
>
> It seems to me that having this command inside my start-commit script
> is not enough. (and I would like to manage the script thru SVN and
> have it automagically installed as a hook).
>
> I believe that this is a common scenario that one want to version a
> file produced by a command (be it a RDBMS dump, or an HTTP client like
> wget, or a GDBM dump...) and to ensure that the SubVersion system
> produces this file (by running this command) before commits.
>
> I'm a bit surprised that such a scenario is not explicitly appearing
> in the documentation. Either I misunderstood something (most probably)
> or maybe something is lacking in the documentation or the SVN
> software.
>
> Any clues or insight please?
>
> Thanks for reading. Regards.
>
> -- 
> Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
> email: basile<at>starynkevitch<dot>net
> aliases: basile<at>tunes<dot>org = bstarynk<at>nerim<dot>net
> 8, rue de la Faïencerie, 92340 Bourg La Reine, France
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
> For additional commands, e-mail: users-help@subversion.tigris.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: versioning a [small] MySQL database with svn?

Posted by Christopher Ness <ch...@nesser.org>.
On Sun, 2005-27-02 at 12:25 -0600, Ben Collins-Sussman wrote:
> I have to admit, I still don't quite understand what you want to do.

Looks to me like he is trying to backup his MySQL data.

I used to do this daily in CVS with a cron job and have it email me if
changes took place.  It allowed me to monitor the table I was interested
in and back up the data.  YMMV.

Cheers,
Chris
-- 
Software Engineering IV,
McMaster University
PGP Public Key: http://www.nesser.org/pgp-key/
13:30:38 up 1:25, 1 user, load average: 0.12, 0.62, 0.64 
http://www.fsf.org/philosophy/no-word-attachments.html

Re: versioning a [small] MySQL database with svn?

Posted by Ed MacDonald <ed...@hotmail.com>.
----- Original Message ----- 
From: "Basile STARYNKEVITCH" <ba...@starynkevitch.net>
Subject: Re: versioning a [small] MySQL database with svn?


> So I will wrap svn commit inside a shell script, but I still believe
> it is a pity that *transforming* commands (like mysqldump) cannot be
> invoked at commit time by the svn commit command.
>
> I still believe that modern version control systems should be able to
> version-control user data which is not in plain textual (or platform
> neutral binary) form, of which a database is a typical example (and I
> listed others). And I don't want to version-control a huge database,
> only a small one. (people think of databases as always being gigabytes
> or terabytes, but it does make sense to use MySQL on a database of a
> few megabytes at most, and to want to version-control it).
>

While I may not fully agree with the use-case as presented, I think the idea
of client-side hooks for *transforming* would be very useful.  For instance
my diff tool accepts plug-ins for pre-processing different files types prior
to a compare.  One example of where it would be useful in SVN is for
applying code formatting tools (jalopy, tidy, etc) prior to check in.  I
know it's not that difficult for a developer to do this sort of thing on
their own before committing.  But the idea here is to help automate and
simplify a work-flow - just like the server-side scripts.

Ed

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: versioning a [small] MySQL database with svn?

Posted by Dirk Schenkewitz <sc...@docomolab-euro.com>.
 > I understand now;  as others have pointed out, you're looking for a
 > *client* hook feature, rather than a server-hook feature.  I believe
 > Clearcase has something like this.
 >
 > To my knowledge, nobody's (yet) voiced much interest in such a feature.
 >  Maybe that will change someday.  In the meantime, yes, you're right --
 > you can simply write a script that does the sqldump and then commits the
 > working copy.

*raises hand* Here is another voice :-)
I can easily imagine further uses of client-side hooks, e.g. setting
certain properties which might need calling something from the OS to
find out what the value should be.

 > But no, it doesn't have client-side scriptability features.


Ben Collins-Sussman wrote:
> 
> On Feb 27, 2005, at 12:41 PM, Basile STARYNKEVITCH wrote:
> 
>> So I will wrap svn commit inside a shell script, but I still believe
>> it is a pity that *transforming* commands (like mysqldump) cannot be
>> invoked at commit time by the svn commit command.

I wholeheartedle agree.

> I understand now;  as others have pointed out, you're looking for a 
> *client* hook feature, rather than a server-hook feature.  I believe 
> Clearcase has something like this.
> 
> To my knowledge, nobody's (yet) voiced much interest in such a feature. 
>  Maybe that will change someday.  In the meantime, yes, you're right -- 
> you can simply write a script that does the sqldump and then commits the 
> working copy.

*raises hand* Here is another voice :-)
I can easily imagine further uses of client-side hooks, e.g. setting
certain properties which might need calling something from the OS to
find out what the value should be.

>  ...
> But no, it doesn't have client-side scriptability features.

IMHO, that's a real pity. Not only because of "lazyness" but rather
because of *safety* - there might be conditions where you can easily
forget to do a pre-commit operation by hand - you may get a message
from svn and the commit will be rejected, ok, but on one hand, that's
rather annoying, on the other hand, there might perhaps certain
circumstances where SVN (on the server) cannot know if the pre-commit
operation has been done. Then it would be safest if the operation is
done automatically during/prior the real commit - on the client.
Of course, it could be done with a wrapper, but that's not so nice
and less safe.

But I also see the problems - the client-side hooks might not be
OS-independent, in case different developers use different OSes.
Under certain circumstances it might be difficult (or even impossible)
to get the same functionality under all involved OSes. But even knowing
this, as a possibility, I definitely want client-side hooks, also!

@ Basile STARYNKEVITCH:
Most likely you already thought of it, but just in case :-) :
You have a Makefile. How about making a target "commit" or "svn-ci"
or something like that and let it first do the conversion/dump and if
that succeeded, let the commit follow. Then you don't need an extra
wrapper script, you only need to remember to never use 'svn commit'
directly.

just my 0.5 cent :-)

Have fun
   Dirk

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: versioning a [small] MySQL database with svn?

Posted by Ben Collins-Sussman <su...@collab.net>.
On Feb 27, 2005, at 12:41 PM, Basile STARYNKEVITCH wrote:
>
> I only want to version control a project made of C source files, a few
> shell scripts, a GNUmakefile, and a MySQL database; of course I don't
> version-control mysql binary files (which are not accessible to me),
> only the result of mysqldump.
>
> So I will wrap svn commit inside a shell script, but I still believe
> it is a pity that *transforming* commands (like mysqldump) cannot be
> invoked at commit time by the svn commit command.

I understand now;  as others have pointed out, you're looking for a 
*client* hook feature, rather than a server-hook feature.  I believe 
Clearcase has something like this.

To my knowledge, nobody's (yet) voiced much interest in such a feature. 
  Maybe that will change someday.  In the meantime, yes, you're right -- 
you can simply write a script that does the sqldump and then commits 
the working copy.


>
> I still believe that modern version control systems should be able to
> version-control user data which is not in plain textual (or platform
> neutral binary) form,

Modern version control systems can version-control anything you want: 
textual, binary, it doesn't matter.  Subversion treats all files as 
opaque collections of bytes, so there are no limits as to what you can 
version-control.

But no, it doesn't have client-side scriptability features.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: versioning a [small] MySQL database with svn?

Posted by Basile STARYNKEVITCH <ba...@starynkevitch.net>.
Le Sun, Feb 27, 2005 at 12:25:40PM -0600, Ben Collins-Sussman
écrivait/wrote:
[...]

> I think you've misunderstood me:  I'm not saying "a repository should 
> never contain anything but source code!" or, "a repository should never 
> contain binary data".  I'm talking about expecting the the version 
> control system to do what a build-system should be doing.

This is probably a matter of terminology. For me, a build system is
building something. And dumping a MySQL database is not building it by
any means (building it would be the opposite - running mysql on the
dump.sql file obtained by mysqldump). More generally, backing up data,
or transforming it into a form suitable for backups and version
control (like the mysqldump command does) is not building.
> 
> I have to admit, I still don't quite understand what you want to do.  
> You want to keep *both* the binary and the textually-dumped data in the 
> repository, both under version control?  [...]


Sorry, I probably explained wrongly what I want to do (I am not a
native english speaker).

I only want to version control a project made of C source files, a few
shell scripts, a GNUmakefile, and a MySQL database; of course I don't
version-control mysql binary files (which are not accessible to me),
only the result of mysqldump.

So I will wrap svn commit inside a shell script, but I still believe
it is a pity that *transforming* commands (like mysqldump) cannot be
invoked at commit time by the svn commit command.

I still believe that modern version control systems should be able to
version-control user data which is not in plain textual (or platform
neutral binary) form, of which a database is a typical example (and I
listed others). And I don't want to version-control a huge database,
only a small one. (people think of databases as always being gigabytes
or terabytes, but it does make sense to use MySQL on a database of a
few megabytes at most, and to want to version-control it).

(For information, the Ocaml binary image I talked about previously is
a bytecode file with a neutral format - like .java files are and it is
versioned under CVS).

A big thanks for your reply.

Regards.
-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/ 
email: basile<at>starynkevitch<dot>net 
aliases: basile<at>tunes<dot>org = bstarynk<at>nerim<dot>net
8, rue de la Faïencerie, 92340 Bourg La Reine, France

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: versioning a [small] MySQL database with svn?

Posted by Ben Collins-Sussman <su...@collab.net>.
On Feb 27, 2005, at 12:02 PM, Basile STARYNKEVITCH wrote:
>
> I believe that SVN should version my data (and I do know which I want
> to version - I won't version object files, except in specific
> circumstances). If my data (as it is the case of a MySQL database)
> happens to be outside the realm of plain textual files, I still want
> the version control system (ie SVN) to manage it, and in my case I
> know precisely what to run to transform this data (my MySQL database)
> into a textual form easily manageable thru SVN (the mysldump
> command). And the dump (thru mysqldump command) of a MySQL database is
> much more portable and persistent than any other representation (eg
> the binary files handled by the mysqld server), and is sensibly
> handled by textual tools (like diff, patch, grep, cat...).
>
> Other scenarii where producing a textual form for SVN before commits
> is useful include:
>
>    other RDBMS databases (postgresql, ...)
>
>    GDBM associative files
>
>    bootstrapped compilers (or processors)
>
>    web pages (in some specific situations ....)
>
>    binary logs transformed to verbose, textual, line-organised formats
>
>    XML data (managed by some XML engine, and dumped in textual XML
>    format)
>

I think you've misunderstood me:  I'm not saying "a repository should 
never contain anything but source code!" or, "a repository should never 
contain binary data".  I'm talking about expecting the the version 
control system to do what a build-system should be doing.

I have to admit, I still don't quite understand what you want to do.  
You want to keep *both* the binary and the textually-dumped data in the 
repository, both under version control?  There's certainly nothing 
preventing you from doing that.  You're free to keep both objects 
side-by-side in the repository.  But it's not the version control 
system's job to "transform" things automatically.  It shouldn't be 
compiling code, or reformatting code, or doing database dumps.  That's 
why build systems exist.

Also, I'm not sure if you read the giant "warning" box on this page:

   http://svnbook.red-bean.com/en/1.1/ch05s02.html#svn-ch-5-sect-2.1

A pre-commit hook script is not allowed to modify the pending commit 
transaction.  At most, it can validate data and reject it.  So that 
particular strategy is out.

It's possible for a post-commit hook to repsond to a commit by doing 
some amount of server-side work -- e.g. update a 'live' website by 
running 'svn update' on some server-side worknig-copy.  But it can get 
very messy if the post-commit hook reacts to every commit by generating 
data and doing another commit:  how to stop the recursion?

In essence, I'm not sure why anything needs huge automation here at 
all.  Keep the binary and textual files side-by-side.  Let the binary 
file change from normal database use.  When you're ready to save 
changes to the repository, run 'mysqldump' on it to generate the text 
file.  Then 'svn commit' both files.  Heck, you could do all of this in 
a nightly cron job.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: versioning a [small] MySQL database with svn?

Posted by Charles Bailey <ba...@gmail.com>.
On Sun, 27 Feb 2005 19:02:23 +0100, Basile STARYNKEVITCH
<ba...@starynkevitch.net> wrote:
> Le Sun, Feb 27, 2005 at 11:30:11AM -0600, Ben Collins-Sussman écrivait/wrote:
> >
> > On Feb 27, 2005, at 11:03 AM, Basile STARYNKEVITCH wrote:
> > >
> > >I believe that this is a common scenario that one want to version a
> > >file produced by a command (be it a RDBMS dump, or an HTTP client like
> > >wget, or a GDBM dump...) and to ensure that the SubVersion system
> > >produces this file (by running this command) before commits.
> >
> > Actually, no, in the general world of version control, it's considered
> > a Bad Practice to put "derived" files under version control.  For
> > example, one doesn't put compiled (.o) files or binaries into the
> > repository.   It's the *source* that gets managed, not the derived
> > objects.
> 
> I knew that, but with e.g. MySQL databases, it is a very bad practise
> to backup (or manage under version control) the MySQL binary data
> files [those under /var/lib/mysql/foo_db/ on my Debian linux machine]
> and it is extremely recommanded to backup using the output of
> mysqldump command. And on my example with MySQL, the source is the
> MySQL database itself which is not a file, or a collection of files,
> or a directory tree (accessible to ordinary users). The only mean I
> can access to my MySQL database is thru SQL requests in the
> libmysqlclient library, which is what the mysqldump does for me.
> >
> > The point of the start- and pre-commit hook scripts are to enforce
> > certain standards, not to generate more data to put in the
> > repository.
> 
> I don't want to "generate" the data, but I just want to "transform"
> the data (a MySQL database in my example and my current concern) into
> a form (textual dump files produced by mysqldump) easily and safely
> manageable by SVN.

While I understand Mr. Collins-Sussman's point, I respectfully
disagree as well,  Certainly, from the perspective of
"responsibility", it's reasonable to expect that a version control
system only consider the integrity of data once it crosses over into
the repository.  In this light, server-side hooks which reject
"inconsistent" changes are enough; it's the commiter's job to do
whatever is necessary to generate appropriate data before committing
it.  From the perspective of "utility" (or perhaps "convenience" or
"laziness"), I can see the benefit in integrating well-defined
"transformations" (be they changes in file or changes in properties)
into the version control system's file transfer process.  True, these
could be done manually, via a build script, or via a wrapper around
the svn invocation on the client side.  But it'd be nice to link them
in a more automagic way to the process of committing changes.

As a minimally-invasive option, perhaps it'd be possible to use two
client-side hooks: a 'prior-to-sending' hook, which would be called
before committing, importing, (and possibly exporting) a file, and an
'after-receiving' hook, which would be called after checking out or
updating a file.  Each might be told the name of the file and the
operation involved.  I don't think either could create an inconsistent
state of the working copy, as long as it didn't play around with
.svn-ish internals.

It would certainly be possible to affect more indirect relationships:
if an 'after-receiving' hook made changes to a file, then that file
would still show as locally modified after 'svn update', and if a
'prior-to-sending' hook modified a file, then 'svn' diff' prior to the
commit and 'svn diff -r PREV:COMMITTED' would show different changes. 
Caveat scriptor.


--
Regards,
Charles Bailey
Lists: bailey _dot_ charles _at_ gmail _dot_ com
Other: bailey _at_ newman _dot_ upenn _dot_ edu

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org


Re: versioning a [small] MySQL database with svn?

Posted by Basile STARYNKEVITCH <ba...@starynkevitch.net>.
Le Sun, Feb 27, 2005 at 11:30:11AM -0600, Ben Collins-Sussman écrivait/wrote:
> 
> On Feb 27, 2005, at 11:03 AM, Basile STARYNKEVITCH wrote:
> >
> >I believe that this is a common scenario that one want to version a
> >file produced by a command (be it a RDBMS dump, or an HTTP client like
> >wget, or a GDBM dump...) and to ensure that the SubVersion system
> >produces this file (by running this command) before commits.
> 
> Actually, no, in the general world of version control, it's considered 
> a Bad Practice to put "derived" files under version control.  For 
> example, one doesn't put compiled (.o) files or binaries into the 
> repository.   It's the *source* that gets managed, not the derived 
> objects.

I knew that, but with e.g. MySQL databases, it is a very bad practise
to backup (or manage under version control) the MySQL binary data
files [those under /var/lib/mysql/foo_db/ on my Debian linux machine]
and it is extremely recommanded to backup using the output of
mysqldump command. And on my example with MySQL, the source is the
MySQL database itself which is not a file, or a collection of files,
or a directory tree (accessible to ordinary users). The only mean I
can access to my MySQL database is thru SQL requests in the
libmysqlclient library, which is what the mysqldump does for me.
> 
> The point of the start- and pre-commit hook scripts are to enforce 
> certain standards, not to generate more data to put in the
> repository.

I don't want to "generate" the data, but I just want to "transform"
the data (a MySQL database in my example and my current concern) into
a form (textual dump files produced by mysqldump) easily and safely
manageable by SVN.
> 
> For example, people often ask if it's possible to make the pre-commit 
> hook reformat code before putting it in the repository.  The answer is, 
> "no, but it can be used to *reject* any commit that doesn't conform to 
> code formatting standards."
> 
> The sort of things you talk about above (making sure Subversion 
> "produces a file" before commits) is the domain of your build system, 
> not your version control system.  


I do know that versioning systems usually don't produce files (BTW, I
used several versioning systems before, my first experience was SCCS
fifteen years ago), but in our world more and more data is not local
files (as my MySQL example shows) - and there are some good reasons to
version some produced file (another common example is a bootstrapped
language implementation - then you want to version-control some form
of "compiled" file, a concrete example I do know quite well is the CVS
of Ocaml -see http://caml.inria.fr/ for more - which contains the
byte-compiled form of the Ocaml compiler, which is necessary to
compile the Ocaml compiler [written itself in ocaml]).

So I respectfully disagree with your current position, even if I did
share it a dozen years ago (when using SCCS, or RCS, or CVS), in the
old time where the only important data I managed (and wanted to
version) was the textual sources files I typed. This is definitely not
the case now, I do want to manage under version control a small MySQL
database (and I could manage also a GDBM binary file -dumpable into a
textual representation- or some kind of XML store).

In addition, MySQL dumps (produced with mysqldump command) are textual
files, which are easily diff-able and patch-able. So there is a point
to wanting the subversion system to mysqldump a (rather small)
database and version the produced dump. It would be foolish to
version-control the mysql binary data files (because you can't
guarantee their integrity while mysqld is running).

We probably both stand at our [previous] position, but I hope I have
given more arguments to defend mine. I fully respect, and still
disagree with, your position (which I happenned to have a dozen years
ago).

I believe that SVN should version my data (and I do know which I want
to version - I won't version object files, except in specific
circumstances). If my data (as it is the case of a MySQL database)
happens to be outside the realm of plain textual files, I still want
the version control system (ie SVN) to manage it, and in my case I
know precisely what to run to transform this data (my MySQL database)
into a textual form easily manageable thru SVN (the mysldump
command). And the dump (thru mysqldump command) of a MySQL database is
much more portable and persistent than any other representation (eg
the binary files handled by the mysqld server), and is sensibly
handled by textual tools (like diff, patch, grep, cat...).

Other scenarii where producing a textual form for SVN before commits
is useful include:

   other RDBMS databases (postgresql, ...)

   GDBM associative files

   bootstrapped compilers (or processors)

   web pages (in some specific situations ....)

   binary logs transformed to verbose, textual, line-organised formats

   XML data (managed by some XML engine, and dumped in textual XML
   format)

It is perfectly sensible to manage all above under a version control
system like SVN (or CVS or Darch or RCS ...) and it is extremly useful
to run a conversion command before commiting. This conversion command
is not a build step - it is a step inside the backup & versioning
procedures!


A big thanks for your reply! Kind regards.


-- 
Basile STARYNKEVITCH         http://starynkevitch.net/Basile/ 
email: basile<at>starynkevitch<dot>net 
aliases: basile<at>tunes<dot>org = bstarynk<at>nerim<dot>net
8, rue de la Faïencerie, 92340 Bourg La Reine, France

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org

Re: versioning a [small] MySQL database with svn?

Posted by Ben Collins-Sussman <su...@collab.net>.
On Feb 27, 2005, at 11:03 AM, Basile STARYNKEVITCH wrote:
>
> I believe that this is a common scenario that one want to version a
> file produced by a command (be it a RDBMS dump, or an HTTP client like
> wget, or a GDBM dump...) and to ensure that the SubVersion system
> produces this file (by running this command) before commits.

Actually, no, in the general world of version control, it's considered 
a Bad Practice to put "derived" files under version control.  For 
example, one doesn't put compiled (.o) files or binaries into the 
repository.   It's the *source* that gets managed, not the derived 
objects.

The point of the start- and pre-commit hook scripts are to enforce 
certain standards, not to generate more data to put in the repository.

For example, people often ask if it's possible to make the pre-commit 
hook reformat code before putting it in the repository.  The answer is, 
"no, but it can be used to *reject* any commit that doesn't conform to 
code formatting standards."

The sort of things you talk about above (making sure Subversion 
"produces a file" before commits) is the domain of your build system, 
not your version control system.  The version control system should be 
enforcing things, not building things.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@subversion.tigris.org
For additional commands, e-mail: users-help@subversion.tigris.org