Skip to content

[change] Squashed migrations 0001-0042 for faster fresh installs #705#739

Open
CodingWithSaksham wants to merge 6 commits into
openwisp:masterfrom
CodingWithSaksham:issues/705-squash-migrations
Open

[change] Squashed migrations 0001-0042 for faster fresh installs #705#739
CodingWithSaksham wants to merge 6 commits into
openwisp:masterfrom
CodingWithSaksham:issues/705-squash-migrations

Conversation

@CodingWithSaksham

Copy link
Copy Markdown
Contributor

Checklist

  • I have read the OpenWISP Contributing Guidelines.
  • I have manually tested the changes proposed in this pull request.
  • I have written new test cases for new code and/or updated existing tests for changes to existing code.
  • I have updated the documentation.

Reference to Existing Issue

Closes #705

Description of Changes

  • Added a squashed migration that consolidates migrations 0001–0042, designated for the 1.2.x release series.
  • Added comments above the functions in migrations/__init__.py indicating that they should be removed as part of the 1.3.x release series.

…wisp#705

Squashed only the migrations released up to 1.2.x (0001-0042) into `0001_squashed_0042_initial`, keeping 0043-0048 (unreleased 1.3.0 work) standalone. Flagged the data-migration helpers used solely by the squashed range in `migrations/__init__.py` for removal in a future release.

Closes openwisp#705
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: f68b0b54-7e99-4469-89b1-0b4d1220b58d

📥 Commits

Reviewing files that changed from the base of the PR and between 345a049 and d6f6ddc.

📒 Files selected for processing (1)
  • openwisp_radius/migrations/0001_squashed_0042_initial.py
💤 Files with no reviewable changes (1)
  • openwisp_radius/migrations/0001_squashed_0042_initial.py
📜 Recent review details
⏰ Context from checks skipped due to timeout. (11)
  • GitHub Check: Python==3.11 | django~=4.2.0
  • GitHub Check: Python==3.10 | django~=5.2.0
  • GitHub Check: Python==3.12 | django~=5.1.0
  • GitHub Check: Python==3.10 | django~=4.2.0
  • GitHub Check: Python==3.10 | django~=5.1.0
  • GitHub Check: Python==3.12 | django~=4.2.0
  • GitHub Check: Python==3.13 | django~=5.1.0
  • GitHub Check: Python==3.11 | django~=5.1.0
  • GitHub Check: Python==3.11 | django~=5.2.0
  • GitHub Check: Python==3.12 | django~=5.2.0
  • GitHub Check: Python==3.13 | django~=5.2.0

📝 Walkthrough

Walkthrough

Adds a squashed Django initial migration that replaces the earlier openwisp_radius migration chain through 0042_set_existing_batches_completed. The migration creates the core RADIUS models, applies data backfills, updates token, phone, batch, and organization setting models, and adds removal-marker comments around existing migration helpers.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the squashed migration work and references the linked issue.
Description check ✅ Passed The description includes the checklist, linked issue, and a clear summary of the migration changes.
Linked Issues check ✅ Passed The PR squashes migrations 0001–0042 to speed fresh installs while preserving upgrade compatibility via replacements.
Out of Scope Changes check ✅ Passed The changes stay focused on the migration squash and related migration comments, with no obvious unrelated additions.
Bug Fixes ✅ Passed This is a migration squash/comment-only maintenance change, not a core bug fix, so the regression-test checklist doesn’t apply.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@openwisp_radius/migrations/0001_squashed_0042_initial.py`:
- Line 1631: The migration references a misspelled helper name, so update the
`code` argument in the squashed migration to use the actual UUID population
function from `openwisp_radius.migrations` (likely `populate_uuids` instead of
`popluate_uuids`). Check the migration’s `code=` callback and the corresponding
function defined in `openwisp_radius/migrations/__init__.py`, then make the
names match exactly so the migration can run without an AttributeError.
- Around line 31-33: The comment in the squashed migration is ambiguous about
which helper came from which source migration. Update the note in
0001_squashed_0042_initial.py around the copied migration helpers so it clearly
maps clean_fallback_fields to 0038_clean_fallbackfields and
set_existing_batches_completed to 0042_set_existing_batches_completed, or split
it into separate comments for each symbol; keep the existing reminder about
squashmigrations and syncing changes.
- Around line 2254-2256: The RunPython migration for
set_existing_batches_completed is missing a reverse_code, which makes backwards
migration stop at this operation. Update the migration entry in the squashed
initial migration to pass a reverse_code using noop, matching the pattern used
for irreversible data migrations. Use the existing
set_existing_batches_completed RunPython call so it can be located even if line
numbers change.
- Around line 1630-1632: The RunPython operation in the migration has a typo in
the UUID population callable name and is missing a reverse_code. Update the
migration to reference the correct UUID population function name, and add
reverse_code=django.db.migrations.operations.special.RunPython.noop to the
migrations.RunPython call so it behaves consistently with the other migration
steps and can be reversed safely.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 56f6b4dd-bd5a-446c-adc5-8e76468412b8

📥 Commits

Reviewing files that changed from the base of the PR and between 072d17e and 4186518.

📒 Files selected for processing (2)
  • openwisp_radius/migrations/0001_squashed_0042_initial.py
  • openwisp_radius/migrations/__init__.py
📜 Review details
⏰ Context from checks skipped due to timeout. (11)
  • GitHub Check: Python==3.11 | django~=5.1.0
  • GitHub Check: Python==3.10 | django~=4.2.0
  • GitHub Check: Python==3.13 | django~=5.2.0
  • GitHub Check: Python==3.11 | django~=5.2.0
  • GitHub Check: Python==3.13 | django~=5.1.0
  • GitHub Check: Python==3.12 | django~=5.1.0
  • GitHub Check: Python==3.12 | django~=5.2.0
  • GitHub Check: Python==3.10 | django~=5.1.0
  • GitHub Check: Python==3.12 | django~=4.2.0
  • GitHub Check: Python==3.10 | django~=5.2.0
  • GitHub Check: Python==3.11 | django~=4.2.0
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Place imports at the top of the file. Only defer imports when necessary (e.g., Django model imports inside functions or methods where the app registry is not yet ready).
Avoid unnecessary blank lines inside function and method bodies.
Mark user-facing strings for translation with Django i18n helpers in Django code.
Write comments and docstrings only when they explain why code is shaped a certain way. Put comments before the relevant code block instead of scattering them inside it.

Files:

  • openwisp_radius/migrations/0001_squashed_0042_initial.py
  • openwisp_radius/migrations/__init__.py
🪛 ast-grep (0.44.0)
openwisp_radius/migrations/0001_squashed_0042_initial.py

[info] 161-166: use help_text to document model columns
Context: models.CharField(
db_index=True,
max_length=255,
unique=True,
verbose_name="group name",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 170-172: use help_text to document model columns
Context: models.CharField(
blank=True, max_length=64, null=True, verbose_name="description"
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 234-239: use help_text to document model columns
Context: models.CharField(
blank=True,
db_index=True,
max_length=64,
verbose_name="group name",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 243-243: use help_text to document model columns
Context: models.CharField(max_length=64, verbose_name="attribute")
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 247-266: use help_text to document model columns
Context: models.CharField(
choices=[
("=", "="),
(":=", ":="),
("==", "=="),
("+=", "+="),
("!=", "!="),
(">", ">"),
(">=", ">="),
("<", "<"),
("<=", "<="),
("=", "="),
("!", "!"),
("=", "="),
("!", "!"),
],
default=":=",
max_length=2,
verbose_name="operator",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 268-268: use help_text to document model columns
Context: models.CharField(max_length=253, verbose_name="value")
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 318-323: use help_text to document model columns
Context: models.CharField(
blank=True,
db_index=True,
max_length=64,
verbose_name="group name",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 327-327: use help_text to document model columns
Context: models.CharField(max_length=64, verbose_name="attribute")
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 331-336: use help_text to document model columns
Context: models.CharField(
choices=[("=", "="), (":=", ":="), ("+=", "+=")],
default="=",
max_length=2,
verbose_name="operator",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 338-338: use help_text to document model columns
Context: models.CharField(max_length=253, verbose_name="value")
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 388-393: use help_text to document model columns
Context: models.CharField(
blank=True,
db_index=True,
max_length=64,
verbose_name="username",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 397-399: use help_text to document model columns
Context: models.CharField(
blank=True, max_length=64, verbose_name="group name"
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 644-646: use help_text to document model columns
Context: models.CharField(
db_column="shortname", max_length=32, verbose_name="short name"
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 650-718: use help_text to document model columns
Context: models.CharField(
choices=[
("cisco", "Cisco Router"),
("Async", "Async"),
("Sync", "Sync"),
("ISDN Sync", "ISDN Sync"),
("ISDN Async V.120", "ISDN Async V.120"),
("ISDN Async V.110", "ISDN Async V.110"),
("Virtual", "Virtual"),
("PIAFS", "PIAFS"),
("HDLC Clear", "HDLC Clear"),
("Channel", "Channel"),
("X.25", "X.25"),
("X.75", "X.75"),
("G.3 Fax", "G.3 Fax"),
("SDSL", "SDSL - Symmetric DSL"),
("ADSL-CAP", "ADSL-CAP"),
("ADSL-DMT", "ADSL-DMT"),
("IDSL", "IDSL"),
("Ethernet", "Ethernet"),
("xDSL", "xDSL"),
("Cable", "Cable"),
("Wireless - Other", "Wireless - Other"),
("IEEE 802.11", "Wireless - IEEE 802.11"),
("Token-Ring", "Token-Ring"),
("FDDI", "FDDI"),
("Wireless - CDMA2000", "Wireless - CDMA2000"),
("Wireless - UMTS", "Wireless - UMTS"),
("Wireless - 1X-EV", "Wireless - 1X-EV"),
("IAPP", "IAPP"),
("FTTP", "FTTP"),
("IEEE 802.16", "Wireless - IEEE 802.16"),
("IEEE 802.20", "Wireless - IEEE 802.20"),
("IEEE 802.22", "Wireless - IEEE 802.22"),
("PPPoA", "PPPoA - PPP over ATM"),
("PPPoEoA", "PPPoEoA - PPP over Ethernet over ATM"),
("PPPoEoE", "PPPoEoE - PPP over Ethernet over Ethernet"),
("PPPoEoVLAN", "PPPoEoVLAN - PPP over Ethernet over VLAN"),
(
"PPPoEoQinQ",
"PPPoEoQinQ - PPP over Ethernet over IEEE 802.1QinQ",
),
("xPON", "xPON - Passive Optical Network"),
("Wireless - XGP", "Wireless - XGP"),
("WiMAX", " WiMAX Pre-Release 8 IWK Function"),
(
"WIMAX-WIFI-IWK",
"WIMAX-WIFI-IWK: WiMAX WIFI Interworking",
),
(
"WIMAX-SFF",
(
"WIMAX-SFF: Signaling Forwarding Function for"
" LTE/3GPP2"
),
),
(
"WIMAX-HA-LMA",
"WIMAX-HA-LMA: WiMAX HA and or LMA function",
),
("WIMAX-DHCP", "WIMAX-DHCP: WIMAX DCHP service"),
("WIMAX-LBS", "WIMAX-LBS: WiMAX location based service"),
("WIMAX-WVS", "WIMAX-WVS: WiMAX voice service"),
("Other", "Other"),
],
default="other",
max_length=30,
verbose_name="type",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 734-736: use help_text to document model columns
Context: models.CharField(
blank=True, max_length=50, null=True, verbose_name="community"
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 740-745: use help_text to document model columns
Context: models.CharField(
blank=True,
max_length=200,
null=True,
verbose_name="description",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 749-751: use help_text to document model columns
Context: models.CharField(
blank=True, max_length=64, null=True, verbose_name="server"
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 783-788: use help_text to document model columns
Context: models.CharField(
db_column="acctsessionid",
db_index=True,
max_length=64,
verbose_name="session ID",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 792-797: use help_text to document model columns
Context: models.CharField(
db_column="acctuniqueid",
max_length=32,
unique=True,
verbose_name="accounting unique ID",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 801-807: use help_text to document model columns
Context: models.CharField(
blank=True,
db_index=True,
max_length=64,
null=True,
verbose_name="username",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 811-813: use help_text to document model columns
Context: models.CharField(
blank=True, max_length=64, null=True, verbose_name="group name"
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 817-819: use help_text to document model columns
Context: models.CharField(
blank=True, max_length=64, null=True, verbose_name="realm"
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 831-837: use help_text to document model columns
Context: models.CharField(
blank=True,
db_column="nasportid",
max_length=15,
null=True,
verbose_name="NAS port ID",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 841-847: use help_text to document model columns
Context: models.CharField(
blank=True,
db_column="nasporttype",
max_length=32,
null=True,
verbose_name="NAS port type",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 880-886: use help_text to document model columns
Context: models.CharField(
blank=True,
db_column="acctauthentic",
max_length=32,
null=True,
verbose_name="authentication",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 890-896: use help_text to document model columns
Context: models.CharField(
blank=True,
db_column="connectinfo_start",
max_length=50,
null=True,
verbose_name="connection info start",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 900-906: use help_text to document model columns
Context: models.CharField(
blank=True,
db_column="connectinfo_stop",
max_length=50,
null=True,
verbose_name="connection info stop",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 928-935: use help_text to document model columns
Context: models.CharField(
blank=True,
db_column="callingstationid",
db_index=True,
max_length=50,
null=True,
verbose_name="calling station ID",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 939-946: use help_text to document model columns
Context: models.CharField(
blank=True,
db_column="calledstationid",
db_index=True,
max_length=50,
null=True,
verbose_name="called station ID",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 950-956: use help_text to document model columns
Context: models.CharField(
blank=True,
db_column="acctterminatecause",
max_length=32,
null=True,
verbose_name="termination cause",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 960-966: use help_text to document model columns
Context: models.CharField(
blank=True,
db_column="servicetype",
max_length=32,
null=True,
verbose_name="service type",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 970-976: use help_text to document model columns
Context: models.CharField(
blank=True,
db_column="framedprotocol",
max_length=32,
null=True,
verbose_name="framed protocol",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 1055-1060: use help_text to document model columns
Context: models.CharField(
blank=True,
db_index=True,
max_length=64,
verbose_name="username",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 1062-1062: use help_text to document model columns
Context: models.CharField(max_length=253, verbose_name="value")
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 1065-1084: use help_text to document model columns
Context: models.CharField(
choices=[
("=", "="),
(":=", ":="),
("==", "=="),
("+=", "+="),
("!=", "!="),
(">", ">"),
(">=", ">="),
("<", "<"),
("<=", "<="),
("=", "="),
("!", "!"),
("=", "="),
("!", "!"),
],
default=":=",
max_length=2,
verbose_name="operator",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 1088-1105: use help_text to document model columns
Context: models.CharField(
choices=[
("Max-Daily-Session", "Max-Daily-Session"),
("Max-All-Session", "Max-All-Session"),
("Max-Daily-Session-Traffic", "Max-Daily-Session-Traffic"),
("Cleartext-Password", "Cleartext-Password"),
("NT-Password", "NT-Password"),
("LM-Password", "LM-Password"),
("MD5-Password", "MD5-Password"),
("SMD5-Password", "SMD5-Password"),
("SHA-Password", "SHA-Password"),
("SSHA-Password", "SSHA-Password"),
("Crypt-Password", "Crypt-Password"),
],
default="NT-Password",
max_length=64,
verbose_name="attribute",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 1154-1154: use help_text to document model columns
Context: models.CharField(max_length=64, verbose_name="username")
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 1157-1162: use help_text to document model columns
Context: models.CharField(
blank=True,
db_column="pass",
max_length=64,
verbose_name="password",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 1164-1164: use help_text to document model columns
Context: models.CharField(max_length=32, verbose_name="reply")
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 1173-1179: use help_text to document model columns
Context: models.CharField(
blank=True,
db_column="calledstationid",
max_length=50,
null=True,
verbose_name="called station ID",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 1183-1189: use help_text to document model columns
Context: models.CharField(
blank=True,
db_column="callingstationid",
max_length=50,
null=True,
verbose_name="calling station ID",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 1240-1245: use help_text to document model columns
Context: models.CharField(
blank=True,
db_index=True,
max_length=64,
verbose_name="username",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 1247-1247: use help_text to document model columns
Context: models.CharField(max_length=253, verbose_name="value")
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 1250-1255: use help_text to document model columns
Context: models.CharField(
choices=[("=", "="), (":=", ":="), ("+=", "+=")],
default="=",
max_length=2,
verbose_name="operator",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 1259-1259: use help_text to document model columns
Context: models.CharField(max_length=64, verbose_name="attribute")
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 1367-1372: use help_text to document model columns
Context: models.CharField(
max_length=40,
primary_key=True,
serialize=False,
verbose_name="Key",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 1394-1401: use help_text to document model columns
Context: models.CharField(
blank=True,
db_column="delegatedipv6prefix",
max_length=44,
null=True,
validators=[openwisp_radius.base.validators.ipv6_network_validator],
verbose_name="delegated IPv6 prefix",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 1406-1412: use help_text to document model columns
Context: models.CharField(
blank=True,
db_column="framedinterfaceid",
max_length=19,
null=True,
verbose_name="framed interface ID",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 1428-1435: use help_text to document model columns
Context: models.CharField(
blank=True,
db_column="framedipv6prefix",
max_length=44,
null=True,
validators=[openwisp_radius.base.validators.ipv6_network_validator],
verbose_name="framed IPv6 prefix",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 1509-1513: use help_text to document model columns
Context: models.CharField(
default=openwisp_radius.utils.generate_sms_token,
editable=False,
max_length=8,
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 1667-1674: use help_text to document model columns
Context: models.CharField(
db_column="acctuniqueid",
max_length=32,
primary_key=True,
serialize=False,
unique=True,
verbose_name="accounting unique ID",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 1916-1916: use help_text to document model columns
Context: models.CharField(max_length=64, verbose_name="attribute")
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 2185-2192: use help_text to document model columns
Context: models.CharField(
blank=True,
db_column="calledstationid",
db_index=True,
max_length=253,
null=True,
verbose_name="called station ID",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 2197-2204: use help_text to document model columns
Context: models.CharField(
blank=True,
db_column="callingstationid",
db_index=True,
max_length=253,
null=True,
verbose_name="calling station ID",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 2209-2215: use help_text to document model columns
Context: models.CharField(
blank=True,
db_column="calledstationid",
max_length=253,
null=True,
verbose_name="called station ID",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 2220-2226: use help_text to document model columns
Context: models.CharField(
blank=True,
db_column="callingstationid",
max_length=253,
null=True,
verbose_name="calling station ID",
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)


[info] 2241-2251: use help_text to document model columns
Context: models.CharField(
choices=[
("pending", "Pending"),
("processing", "Processing"),
("completed", "Completed"),
("failed", "Failed"),
],
db_index=True,
default="pending",
max_length=16,
)
Note: [CWE-710] Improper Adherence to Coding Standards.

(model-help-text)

🔇 Additional comments (9)
openwisp_radius/migrations/0001_squashed_0042_initial.py (2)

34-60: 🩺 Stability & Availability

No action needed regarding clean_fallback_fields historical model handling.

The function relies on get_fields() filtered by isinstance(field, FallbackMixin). In Django, FallbackMixin filters to actual field instances, safely excluding reverse relations and auto-created fields even on historical models. The search for OPENWISP_RADIUS_ORGANIZATIONRADIUSSETTINGS yielded no results, indicating the model follows the default AUTH_USER_MODEL-style swappability pattern where get_swapped_model resolves correctly without custom swappable settings. Since this logic is a direct copy of a working migration and the swappable configuration is standard, the approach is robust and does not require the suggested include_parents arguments or manual re-verification.


122-129: 🗄️ Data Integrity & Integration

Manually verify swapper dependency version against pinned openwisp-users release

The migration swapper.dependency(*swapper.split(settings.AUTH_USER_MODEL), version="0004_default_groups") references a migration that must exist in the openwisp-users package pinned to version 1.3 (via GitHub tarball in setup.py).

Since the referenced package is not locally available for inspection, please confirm that 0004_default_groups.py exists in the openwisp_users/migrations/ directory of the openwisp-users v1.3 release. If the migration filename differs (e.g., due to renaming or reordering in that specific commit), update the version string in the dependency to match the actual filename (excluding .py).

openwisp_radius/migrations/__init__.py (7)

346-356: LGTM!


380-382: LGTM!


391-393: LGTM!


418-431: LGTM!


474-476: LGTM!


494-496: LGTM!


346-501: No action required: comments are accurate.

The comments correctly state these helpers are used only by the squashed 0001‑0042 migration. A codebase search found no external references in tests, newer migrations, or other modules. The planned removal in 1.3.x is safe.

Comment thread openwisp_radius/migrations/0001_squashed_0042_initial.py Outdated
Comment thread openwisp_radius/migrations/0001_squashed_0042_initial.py Outdated
Comment thread openwisp_radius/migrations/0001_squashed_0042_initial.py Outdated
Comment thread openwisp_radius/migrations/0001_squashed_0042_initial.py Outdated
@openwisp-companion

Copy link
Copy Markdown

Migration Failure: Duplicate Column Name

Hello @CodingWithSaksham,
(Analysis for commit 4186518)

There's a django.db.utils.OperationalError: error in table nas after rename: duplicate column name: id. This indicates an issue during the database migration process where a column named id is being added to the nas table, but it already exists.

To fix this:

  1. Review the migration files: Examine the migration files related to the nas table, specifically openwisp_radius/management/commands/upgrade_from_django_freeradius.py and any related migrations in openwisp_radius/management/commands/base/. Look for changes that might be attempting to add an id column when one already exists.
  2. Correct the migration: You might need to adjust the migration to either remove the redundant id column definition or ensure it's handled correctly during the schema alteration.
  3. Re-run migrations: After fixing the migration file, ensure that migrations are applied correctly.

This error is preventing the tests from running. Please address this migration issue and push a new commit.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
openwisp_radius/migrations/0001_squashed_0042_initial.py (1)

2049-2058: 🎯 Functional Correctness | 🔴 Critical

Remove the invalid RenameIndex operations using old_fields.

The migrations.RenameIndex actions at lines 2049–2058 use the argument old_fields, which is not supported by Django's standard RenameIndex operation (it requires old_name and new_name). Since no custom RenameIndex class exists in the codebase, this migration will fail with a TypeError during execution. Additionally, the phonetoken model already creates indexes with these exact names at lines 1524–1532, making these operations redundant. Delete these two lines.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@openwisp_radius/migrations/0001_squashed_0042_initial.py` around lines 2049 -
2058, The migration contains invalid and redundant RenameIndex operations in the
phonetoken migration block. Remove the two migrations.RenameIndex entries in the
squashed initial migration that use old_fields, since Django’s standard
RenameIndex expects old_name/new_name and the phonetoken indexes are already
created earlier by the model’s index definitions.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@openwisp_radius/migrations/0001_squashed_0042_initial.py`:
- Around line 2049-2058: The migration contains invalid and redundant
RenameIndex operations in the phonetoken migration block. Remove the two
migrations.RenameIndex entries in the squashed initial migration that use
old_fields, since Django’s standard RenameIndex expects old_name/new_name and
the phonetoken indexes are already created earlier by the model’s index
definitions.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 167d65b1-ee32-4cbe-a49e-7ec52ce8dfe8

📥 Commits

Reviewing files that changed from the base of the PR and between 4186518 and 345a049.

📒 Files selected for processing (1)
  • openwisp_radius/migrations/0001_squashed_0042_initial.py
📜 Review details
🧰 Additional context used
📓 Path-based instructions (1)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

**/*.py: Place imports at the top of the file. Only defer imports when necessary (e.g., Django model imports inside functions or methods where the app registry is not yet ready).
Avoid unnecessary blank lines inside function and method bodies.
Mark user-facing strings for translation with Django i18n helpers in Django code.
Write comments and docstrings only when they explain why code is shaped a certain way. Put comments before the relevant code block instead of scattering them inside it.

Files:

  • openwisp_radius/migrations/0001_squashed_0042_initial.py
🔇 Additional comments (1)
openwisp_radius/migrations/0001_squashed_0042_initial.py (1)

2074-2076: Duplicate: add reverse_code for the batch-status data migration.

This same set_existing_batches_completed RunPython operation was already flagged in a previous review for missing reverse_code=django.db.migrations.operations.special.RunPython.noop.

@coveralls

coveralls commented Jun 26, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 98.091%. remained the same — CodingWithSaksham:issues/705-squash-migrations into openwisp:master

@CodingWithSaksham

Copy link
Copy Markdown
Contributor Author

@coderabbitai resolve

coderabbitai[bot]
coderabbitai Bot previously approved these changes Jun 26, 2026
@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
✅ Action performed

Comments resolved and changes approved.

@nemesifier nemesifier left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK on postgres we can't run DB schema changes and data migrations in one single run, see https://stackoverflow.com/a/66799446/462707.

Moreover, some data migrations won't be necessary if migrations are squashed so it may be that we don't have to run them at all. Others, like the addition of the permissions to operator and administrator groups will always be necessary and we need to maintain them.

@github-project-automation github-project-automation Bot moved this from Backlog to In progress in 26.06 Release Jun 26, 2026
@github-project-automation github-project-automation Bot moved this from Reviewer approved to In progress in OpenWISP Priorities for next releases Jun 26, 2026
@openwisp-companion

Copy link
Copy Markdown

The CI is failing due to transient infrastructure issues (not related to your code). I have restarted the failed jobs automatically (1/3).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

Status: In progress

Development

Successfully merging this pull request may close these issues.

[change] Squash and Reduce Migrations for Faster Installation

3 participants