aboutsummaryrefslogtreecommitdiffstats
path: root/posts
diff options
context:
space:
mode:
authorFran├žois Kooman <fkooman@tuxed.net>2018-06-25 15:35:16 +0200
committerFran├žois Kooman <fkooman@tuxed.net>2018-06-25 15:35:16 +0200
commit4e063aa3ebda669398b439e5ce0f7ca56ff64b71 (patch)
tree89533267440ed64fbed064e6e60aeda52971edc4 /posts
parent11b6d9c01a65cfdfac8629bcd8a65ab6c7b11893 (diff)
downloadwww.tuxed.net-4e063aa3ebda669398b439e5ce0f7ca56ff64b71.zip
www.tuxed.net-4e063aa3ebda669398b439e5ce0f7ca56ff64b71.tar.gz
www.tuxed.net-4e063aa3ebda669398b439e5ce0f7ca56ff64b71.tar.xz
update post
Diffstat (limited to 'posts')
-rw-r--r--posts/php_database_migrations.md11
1 files changed, 7 insertions, 4 deletions
diff --git a/posts/php_database_migrations.md b/posts/php_database_migrations.md
index b64db01..52ff330 100644
--- a/posts/php_database_migrations.md
+++ b/posts/php_database_migrations.md
@@ -1,8 +1,11 @@
---
title: PHP Database Migrations
published: 2018-06-19
+modified: 2018-06-25
---
+**UPDATE** (2018-06-25): use `;` now in example migration.
+
While working on [Let's Connect!](https://letsconnect-vpn.org/) /
[eduVPN](https://eduvpn.org/) I reached the point of needing to perform a
database migration, i.e. modify the database schema. I wanted to add a column
@@ -43,10 +46,10 @@ long as possible...
With SQLite most migrations will require creating a new table, copy the old
data in and remove the old table. As an example:
- ALTER TABLE foo RENAME TO _foo
- CREATE TABLE foo (a INTEGER NOT NULL, b INTEGER DEFAULT 0)
- INSERT INTO foo (a) SELECT a FROM _foo
- DROP TABLE _foo
+ ALTER TABLE foo RENAME TO _foo;
+ CREATE TABLE foo (a INTEGER NOT NULL, b INTEGER DEFAULT 0);
+ INSERT INTO foo (a) SELECT a FROM _foo;
+ DROP TABLE _foo;
This example renames the existing table `foo` to `_foo`, creates a new table
`foo` with the additional column `b` and copies the data from `_foo` back to