<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Sqlalchemy on Random notes from mg</title>
    <link>https://mg.pov.lt/blog/tags/sqlalchemy.html</link>
    <description>Recent content in Sqlalchemy on Random notes from mg</description>
    <generator>Hugo -- gohugo.io</generator>
    <language>en-us</language>
    <managingEditor>marius@gedmin.as (Marius Gedminas)</managingEditor>
    <webMaster>marius@gedmin.as (Marius Gedminas)</webMaster>
    <copyright>Copyright © 2004–2020 Marius Gedminas</copyright>
    <lastBuildDate>Mon, 21 Sep 2009 18:44:14 +0200</lastBuildDate>
    <atom:link href="https://mg.pov.lt/blog/tags/sqlalchemy/index.xml" rel="self" type="application/rss+xml" />
    
    <item>
      <title>Pylons and SQL schema migration</title>
      <link>https://mg.pov.lt/blog/pylons-and-sql-migration.html</link>
      <pubDate>Mon, 21 Sep 2009 18:44:14 +0200</pubDate>
      <author>marius@gedmin.as (Marius Gedminas)</author>
      <guid>https://mg.pov.lt/blog/pylons-and-sql-migration.html</guid>
      <description>
&lt;p&gt;I&#39;m at the point in my hobby project where I&#39;d like to be able to change my models
without losing all my test data.  And I&#39;m too lazy to do manual dumps and edit
the SQL in place before reimporting it.&lt;/p&gt;

&lt;p&gt;I want a system&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;that is &lt;em&gt;transparent&lt;/em&gt; to the user: if my database is at schema
      version 1, and my code is at version 3, I want it to be automatically
      upgraded to version 3 on server startup.&lt;/li&gt;
  &lt;li&gt;that is &lt;em&gt;not too hard&lt;/em&gt; on the programmer: dropping a numbered Python or SQL
      script in a directory ought to be sufficient to define a transition from
      schema version X to schema version X+1.&lt;/li&gt;
  &lt;li&gt;that &lt;em&gt;handles errors gracefully&lt;/em&gt;: makes a backup of the database
      with the old schema version; runs my script in a transaction and aborts
      that transaction if the conversion fails (while showing me enough
      information to debug the problem).&lt;/li&gt;
  &lt;li&gt;&lt;em&gt;allows prototyping&lt;/em&gt; without having to increment the schema number for every
      little change I make to the models; I should be the one who decides that a new
      schema is ready to go out to the world.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I&#39;ve been glancing at &lt;a
  href=&#34;http://code.google.com/p/sqlalchemy-migrate/&#34;&gt;SQLAlchemy-Migrate&lt;/a&gt;, since I&#39;ve
been brought up to believe &lt;abbr title=&#34;Not Invented Here&#34;&gt;NIH&lt;/abbr&gt;ing is
Bad.  But Migrate is &lt;em&gt;scary&lt;/em&gt;.  I have to admit that the longer I stare
at its documentation, the less I can describe &lt;em&gt;why&lt;/em&gt; I think so.  All
those shell commands&amp;mdash;but there&#39;s an API for invoking them from Python, so maybe I can
achieve my goals.  I&#39;ll have to try and see.
&lt;/p&gt;

</description>
    </item>
    
  </channel>
</rss>
