diff --git a/app/models/modules.py b/app/models/modules.py
index 393cc8c0f..5a5f47618 100644
--- a/app/models/modules.py
+++ b/app/models/modules.py
@@ -34,7 +34,7 @@ class Module(db.Model):
     # id de l'element pedagogique Apogee correspondant:
     code_apogee = db.Column(db.String(APO_CODE_STR_LEN))
     # Type: ModuleType: DEFAULT, MALUS, RESSOURCE, MODULE_SAE (enum)
-    module_type = db.Column(db.Integer)
+    module_type = db.Column(db.Integer, nullable=False, default=0, server_default="0")
     # Relations:
     modimpls = db.relationship("ModuleImpl", backref="module", lazy="dynamic")
     ues_apc = db.relationship("UniteEns", secondary="module_ue_coef", viewonly=True)
diff --git a/migrations/versions/b9aadc10227f_module_type_non_null.py b/migrations/versions/b9aadc10227f_module_type_non_null.py
new file mode 100644
index 000000000..1758c3d23
--- /dev/null
+++ b/migrations/versions/b9aadc10227f_module_type_non_null.py
@@ -0,0 +1,41 @@
+"""module_type_non_null
+
+Revision ID: b9aadc10227f
+Revises: bd2c1c3d866e
+Create Date: 2022-02-15 21:47:29.212329
+
+"""
+from alembic import op
+import sqlalchemy as sa
+from sqlalchemy.dialects import postgresql
+from sqlalchemy.orm import sessionmaker  # added by ev
+
+# revision identifiers, used by Alembic.
+revision = "b9aadc10227f"
+down_revision = "bd2c1c3d866e"
+branch_labels = None
+depends_on = None
+
+Session = sessionmaker()
+
+
+def upgrade():
+    # Added by ev: remove duplicates
+    bind = op.get_bind()
+    session = Session(bind=bind)
+    session.execute(
+        """UPDATE notes_modules SET module_type=0 WHERE module_type IS NULL;"""
+    )
+    # ### commands auto generated by Alembic - please adjust! ###
+    op.alter_column(
+        "notes_modules", "module_type", existing_type=sa.INTEGER(), nullable=False
+    )
+    # ### end Alembic commands ###
+
+
+def downgrade():
+    # ### commands auto generated by Alembic - please adjust! ###
+    op.alter_column(
+        "notes_modules", "module_type", existing_type=sa.INTEGER(), nullable=True
+    )
+    # ### end Alembic commands ###