X-Received: by 10.236.101.148 with SMTP id b20mr5485179yhg.46.1409316958070; Fri, 29 Aug 2014 05:55:58 -0700 (PDT) X-Received: by 10.50.85.7 with SMTP id d7mr83475igz.9.1409316957884; Fri, 29 Aug 2014 05:55:57 -0700 (PDT) Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!i13no4123863qae.1!news-out.google.com!ef6ni0igb.0!nntp.google.com!r2no9899838igi.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.python Date: Fri, 29 Aug 2014 05:55:57 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=59.95.22.176; posting-account=mBpa7woAAAAGLEWUUKpmbxm-Quu5D8ui NNTP-Posting-Host: 59.95.22.176 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <1cdf6e52-e09b-40f1-8db1-db6cbbee9512@googlegroups.com> Subject: Re: Keeping python code and database in sync From: Rustom Mody Injection-Date: Fri, 29 Aug 2014 12:55:57 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: csiph.com comp.lang.python:77271 On Friday, August 29, 2014 6:12:06 PM UTC+5:30, Frank Millman wrote: > Hi all > Now that I have bitten the bullet and published my repository, I am forced > to change my working practices (which is a good thing!). > The project is inherently database-driven. The python code expects to find > certain tables and columns in the database. As I develop new features, I > sometimes need to modify the database structure. In the bad old days (like > yesterday) I would just make the modifications and carry on. Now I have to > be aware that others may have downloaded the project, so I have to consider > how to ensure that their database is kept up to date. There are tools like this http://alembic.readthedocs.org/en/latest/ It may help to read that to avoid reinvention > It is a simple matter to write a program that updates the database > automatically. The question is, what should trigger such an update? My first > thought is to use a version number - store a version number in the working > directory, and have a matching number in the code. If someone downloads the > latest version, the numbers will no longer match, and I can run the upgrade > program. > The problem with that is that version numbers are usually reserved for > tagged releases, but this could happen as the result of any commit in the > current development cycle. I dont think alembic can solve that. Still it may help to study it