Anonymous avatar Anonymous committed 2ed3d95

Add " NOT NULL" to column definition if null_ok == False

Comments (0)

Files changed (1)

south/db/sqlite3.py

         # Work out new column defs.
         for column_info in self._get_connection().introspection.get_table_description(cursor, table_name):
             name = column_info[0]
+            null_ok = column_info[6]
             if name in deleted:
                 continue
             # Get the type, ignoring PRIMARY KEY (we need to be consistent)
             type = column_info[1].replace("PRIMARY KEY", "")
-            # Add on unique or primary key if needed.
-            if indexes[name]['unique'] and name not in uniques_deleted:
-                type += " UNIQUE"
+            # Add on primary key, not null or unique if needed.
             if (primary_key_override and primary_key_override == name) or \
                (not primary_key_override and indexes[name]['primary_key']):
                 type += " PRIMARY KEY"
+            elif not null_ok:
+                type += " NOT NULL"
+            if indexes[name]['unique'] and name not in uniques_deleted:
+                type += " UNIQUE"
             # Deal with a rename
             if name in renames:
                 name = renames[name]
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.