about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--migrations/2018-05-01-141548_add-users/up.sql16
1 files changed, 11 insertions, 5 deletions
diff --git a/migrations/2018-05-01-141548_add-users/up.sql b/migrations/2018-05-01-141548_add-users/up.sql
index 222afc485afe..5fadeeb23a00 100644
--- a/migrations/2018-05-01-141548_add-users/up.sql
+++ b/migrations/2018-05-01-141548_add-users/up.sql
@@ -8,11 +8,17 @@ CREATE TABLE users (
   admin BOOLEAN NOT NULL DEFAULT false
 );
 
-INSERT INTO users (email, name)
-SELECT author_email AS email,
-       author_name AS name
-FROM posts
-GROUP BY name, email;
+-- Insert the 'anonymous' user explicitly:
+INSERT INTO users (name, email)
+  VALUES ('Anonymous', 'anonymous@nothing.org');
+
+INSERT INTO users (id, email, name)
+  SELECT nextval('users_id_seq'),
+         author_email AS email,
+         author_name AS name
+  FROM posts
+  WHERE author_email != 'anonymous@nothing.org'
+  GROUP BY name, email;
 
 -- Create the 'author' column in the relevant tables (initially
 -- without a not-null constraint) and populate it with the data