Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I tend to function best with 'migration' scripts, which are the next stage up from a simple versioned script. With a migration, you specify the changes to the database (additions, removals, etc) and also how to undo the changes your migration is performing. This is then tagged with a version of some form that won't clash with other developers. A particularly good version number is the current time (in either YYYYMMDDHHMMSS format or just as seconds from the epoch). This is a good choice because you are very unlikely to get version clashes and it is still very easy to see if new versions exists due to the strictly increasing nature of such timestamps.</p> <p>Note: This is very much influenced by the migration system in Rails. For more details and ideas I would highly recommend looking into that system.</p> <p>Rails migration:</p> <pre><code>class CreateGroups &lt; ActiveRecord::Migration def self.up create_table :groups do |t| t.string :name t.references :owner t.timestamps end end def self.down drop_table :groups end end </code></pre> <p>Doctrine migration:</p> <pre><code>class CreateGroups extends Doctrine_Migration { public function up() { // Create new author table $columns = array('id' =&gt; array('type' =&gt; 'integer', 'length' =&gt; 4, 'autoincrement' =&gt; true), 'name' =&gt; array('type' =&gt; 'string', 'length' =&gt; 255), 'owner_id' =&gt; array('type' =&gt; 'integer', 'length' =&gt; 4)); $this-&gt;createTable('groups', $columns, array('primary' =&gt; array('id'))); } public function down() { $this-&gt;dropTable('groups'); } } </code></pre> <p>(sorry for lack of timestamps in doctrine... in rails the timestamps call adds in created_at and updated_at fields to the table that are automatically managed for you. I'm not sure of similar behaviour in doctrine so I left them out).</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload