diff options
-rwxr-xr-x | bin/update-schema | 8 | ||||
-rw-r--r-- | db/schema.sql | 5 | ||||
-rw-r--r-- | db/schema_0030-drop-action-log-check-constraint.sql | 6 |
3 files changed, 15 insertions, 4 deletions
diff --git a/bin/update-schema b/bin/update-schema index 92868e1b6..ef33b82a7 100755 --- a/bin/update-schema +++ b/bin/update-schema @@ -85,6 +85,7 @@ print "Nothing to do\n" if $nothing; # By querying the database schema, we can see where we're currently at # (assuming schema change files are never half-applied, which should be the case) sub get_db_version { + return '0030' if ! constraint_exists('admin_log_action_check'); return '0029' if column_exists('body', 'deleted'); return '0028' if table_exists('body'); return '0027' if column_exists('problem', 'subcategory'); @@ -134,3 +135,10 @@ sub column_like { my ( $table, $where, $column, $contents ) = @_; return dbh()->selectrow_array("select count(*) from $table WHERE $where AND $column LIKE ?", {}, "%$contents%"); } + +# Returns true if a check constraint on a table exists +sub constraint_exists { + my ( $constraint ) = @_; + return dbh()->selectrow_array('select count(*) from pg_constraint where conname = ?', {}, $constraint); +} + diff --git a/db/schema.sql b/db/schema.sql index 5c54e2d88..125e680c6 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -448,9 +448,6 @@ create table admin_log ( or object_type = 'user' ), object_id integer not null, - action text not null check ( - action = 'edit' - or action = 'state_change' - or action = 'resend'), + action text not null, whenedited timestamp not null default ms_current_timestamp() ); diff --git a/db/schema_0030-drop-action-log-check-constraint.sql b/db/schema_0030-drop-action-log-check-constraint.sql new file mode 100644 index 000000000..dfc5387f3 --- /dev/null +++ b/db/schema_0030-drop-action-log-check-constraint.sql @@ -0,0 +1,6 @@ +BEGIN; + +ALTER TABLE admin_log + DROP CONSTRAINT admin_log_action_check; + +COMMIT; |