Commits

shaib committed 80430dc

Make Sqlite backend comply with new "no defaults left in db" policy

  • Participants
  • Parent commits 96b2fa6
  • Branches dont-leave-defaults

Comments (0)

Files changed (1)

File south/db/sqlite3.py

         self._remake_table(table_name, added={
             field.column: self._column_sql_for_create(table_name, name, field, False),
         })
+        # Now, remove any defaults
+        field._suppress_default = True
+        self.alter_column(table_name, name, field)
 
     def _get_full_table_description(self, connection, cursor, table_name):
         cursor.execute('PRAGMA table_info(%s)' % connection.ops.quote_name(table_name))
         The argument is accepted for API compatibility with the generic
         DatabaseOperations.alter_column() method.
         """
+        # Change nulls to default if needed
+        if not field.null and field.has_default():
+            params = {
+                "column": self.quote_name(name),
+                "table_name": self.quote_name(table_name)
+            }            
+            self._update_nulls_to_default(params, field)
         # Remake the table correctly
+        field._suppress_default = True
         self._remake_table(table_name, altered={
             name: self._column_sql_for_create(table_name, name, field, explicit_name),
         })