"""
Data migration: enrich the public catalog with additional firearms (pistols,
semi-auto rifles, rimfire), scopes (with adjustment_unit/focal_plane),
suppressors, bipods and magazines.

All items use get_or_create() to be idempotent.
"""
from django.db import migrations


def _get(apps, model_name):
    return apps.get_model('gears', model_name)


def add_firearms(apps, schema_editor):
    Firearm = _get(apps, 'Firearm')
    V = 'VERIFIED'

    items = [
        # ── Pistols ─────────────────────────────────────────────────────────
        dict(brand='Glock', model_name='G17 Gen5', gear_type='FIREARM',
             firearm_type='PISTOL', caliber='9mm Luger', action='SEMI-AUTO',
             barrel_length_mm=114, magazine_capacity=17, status=V),
        dict(brand='Glock', model_name='G19 Gen5', gear_type='FIREARM',
             firearm_type='PISTOL', caliber='9mm Luger', action='SEMI-AUTO',
             barrel_length_mm=102, magazine_capacity=15, status=V),
        dict(brand='Glock', model_name='G34 Gen5 MOS', gear_type='FIREARM',
             firearm_type='PISTOL', caliber='9mm Luger', action='SEMI-AUTO',
             barrel_length_mm=135, magazine_capacity=17, status=V),
        dict(brand='Glock', model_name='G19X', gear_type='FIREARM',
             firearm_type='PISTOL', caliber='9mm Luger', action='SEMI-AUTO',
             barrel_length_mm=102, magazine_capacity=17, status=V),
        dict(brand='Glock', model_name='G45', gear_type='FIREARM',
             firearm_type='PISTOL', caliber='9mm Luger', action='SEMI-AUTO',
             barrel_length_mm=114, magazine_capacity=17, status=V),
        dict(brand='SIG Sauer', model_name='P320 M17', gear_type='FIREARM',
             firearm_type='PISTOL', caliber='9mm Luger', action='SEMI-AUTO',
             barrel_length_mm=112, magazine_capacity=17, status=V),
        dict(brand='SIG Sauer', model_name='P320 X5 Legion', gear_type='FIREARM',
             firearm_type='PISTOL', caliber='9mm Luger', action='SEMI-AUTO',
             barrel_length_mm=127, magazine_capacity=21, status=V),
        dict(brand='SIG Sauer', model_name='P226', gear_type='FIREARM',
             firearm_type='PISTOL', caliber='9mm Luger', action='SEMI-AUTO',
             barrel_length_mm=112, magazine_capacity=15, status=V),
        dict(brand='SIG Sauer', model_name='P226 Legion', gear_type='FIREARM',
             firearm_type='PISTOL', caliber='9mm Luger', action='SEMI-AUTO',
             barrel_length_mm=112, magazine_capacity=15, status=V),
        dict(brand='CZ', model_name='Shadow 2', gear_type='FIREARM',
             firearm_type='PISTOL', caliber='9mm Luger', action='SEMI-AUTO',
             barrel_length_mm=120, magazine_capacity=17, status=V),
        dict(brand='CZ', model_name='SP-01 Tactical', gear_type='FIREARM',
             firearm_type='PISTOL', caliber='9mm Luger', action='SEMI-AUTO',
             barrel_length_mm=119, magazine_capacity=18, status=V),
        dict(brand='Beretta', model_name='92FS', gear_type='FIREARM',
             firearm_type='PISTOL', caliber='9mm Luger', action='SEMI-AUTO',
             barrel_length_mm=125, magazine_capacity=15, status=V),
        dict(brand='Beretta', model_name='APX A1', gear_type='FIREARM',
             firearm_type='PISTOL', caliber='9mm Luger', action='SEMI-AUTO',
             barrel_length_mm=108, magazine_capacity=15, status=V),
        dict(brand='Smith & Wesson', model_name='M&P 2.0 5" Pro', gear_type='FIREARM',
             firearm_type='PISTOL', caliber='9mm Luger', action='SEMI-AUTO',
             barrel_length_mm=127, magazine_capacity=17, status=V),
        dict(brand='Smith & Wesson', model_name='M&P 2.0 Compact 4"', gear_type='FIREARM',
             firearm_type='PISTOL', caliber='9mm Luger', action='SEMI-AUTO',
             barrel_length_mm=102, magazine_capacity=15, status=V),
        dict(brand='HK', model_name='VP9', gear_type='FIREARM',
             firearm_type='PISTOL', caliber='9mm Luger', action='SEMI-AUTO',
             barrel_length_mm=108, magazine_capacity=15, status=V),
        dict(brand='HK', model_name='USP Tactical 9mm', gear_type='FIREARM',
             firearm_type='PISTOL', caliber='9mm Luger', action='SEMI-AUTO',
             barrel_length_mm=123, magazine_capacity=15, status=V),
        dict(brand='Walther', model_name='Q5 Match Steel Frame', gear_type='FIREARM',
             firearm_type='PISTOL', caliber='9mm Luger', action='SEMI-AUTO',
             barrel_length_mm=127, magazine_capacity=15, status=V),
        dict(brand='Walther', model_name='PPQ M2 5"', gear_type='FIREARM',
             firearm_type='PISTOL', caliber='9mm Luger', action='SEMI-AUTO',
             barrel_length_mm=127, magazine_capacity=15, status=V),
        dict(brand='FN', model_name='FN 509 Tactical', gear_type='FIREARM',
             firearm_type='PISTOL', caliber='9mm Luger', action='SEMI-AUTO',
             barrel_length_mm=121, magazine_capacity=17, status=V),
        dict(brand='Canik', model_name='TP9SFx', gear_type='FIREARM',
             firearm_type='PISTOL', caliber='9mm Luger', action='SEMI-AUTO',
             barrel_length_mm=127, magazine_capacity=20, status=V),
        dict(brand='Springfield Armory', model_name='XD-M Elite 5.25" OSP', gear_type='FIREARM',
             firearm_type='PISTOL', caliber='9mm Luger', action='SEMI-AUTO',
             barrel_length_mm=133, magazine_capacity=22, status=V),
        # ── Semi-auto rifles ─────────────────────────────────────────────────
        dict(brand='HK', model_name='HK416 A5 14.5"', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='5.56x45mm NATO', action='SEMI-AUTO',
             barrel_length_mm=368, magazine_capacity=30, status=V),
        dict(brand='HK', model_name='HK417 A2 16"', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='7.62x51mm NATO', action='SEMI-AUTO',
             barrel_length_mm=406, magazine_capacity=20, status=V),
        dict(brand='SIG Sauer', model_name='MCX Spear 16"', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='6.8x51mm', action='SEMI-AUTO',
             barrel_length_mm=406, magazine_capacity=20, status=V),
        dict(brand='FN', model_name='SCAR 16S', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='5.56x45mm NATO', action='SEMI-AUTO',
             barrel_length_mm=406, magazine_capacity=30, status=V),
        dict(brand='FN', model_name='SCAR 17S', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='7.62x51mm NATO', action='SEMI-AUTO',
             barrel_length_mm=406, magazine_capacity=20, status=V),
        dict(brand='Daniel Defense', model_name='DDM4 V7 16"', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='5.56x45mm NATO', action='SEMI-AUTO',
             barrel_length_mm=406, magazine_capacity=30, status=V),
        dict(brand='Bravo Company Mfg', model_name='Recce-16 MCMR', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='5.56x45mm NATO', action='SEMI-AUTO',
             barrel_length_mm=406, magazine_capacity=30, status=V),
        dict(brand='JP Enterprises', model_name='JP-5 16" PCC', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='9mm Luger', action='SEMI-AUTO',
             barrel_length_mm=406, magazine_capacity=17, status=V),
        dict(brand='SIG Sauer', model_name='MCX Rattler 5.5"', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='300 Blackout', action='SEMI-AUTO',
             barrel_length_mm=140, magazine_capacity=30, status=V),
        # ── Rimfire ──────────────────────────────────────────────────────────
        dict(brand='Ruger', model_name='10/22 Carbine', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='.22 LR', action='SEMI-AUTO',
             barrel_length_mm=470, magazine_capacity=10, status=V),
        dict(brand='Ruger', model_name='American Rimfire .22 LR', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='.22 LR', action='BOLT',
             barrel_length_mm=559, magazine_capacity=10, status=V),
        dict(brand='CZ', model_name='457 American .22 LR', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='.22 LR', action='BOLT',
             barrel_length_mm=508, magazine_capacity=5, status=V),
        dict(brand='CZ', model_name='457 Varmint .22 LR', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='.22 LR', action='BOLT',
             barrel_length_mm=610, magazine_capacity=5, status=V),
        dict(brand='Anschütz', model_name='1710 D HB .22 LR', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='.22 LR', action='BOLT',
             barrel_length_mm=660, magazine_capacity=5, status=V),
        dict(brand='Anschütz', model_name='2013 Supermatch .22 LR', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='.22 LR', action='BOLT',
             barrel_length_mm=690, magazine_capacity=1, status=V),
        # ── Additional bolt-action rifles ────────────────────────────────────
        dict(brand='CZ', model_name='600 Alpha .308', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='.308 Win', action='BOLT',
             barrel_length_mm=560, status=V),
        dict(brand='CZ', model_name='600 Range .308', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='.308 Win', action='BOLT',
             barrel_length_mm=660, status=V),
        dict(brand='Christensen Arms', model_name='Modern Precision Rifle 6.5CM', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='6.5 Creedmoor', action='BOLT',
             barrel_length_mm=610, status=V),
        dict(brand='Christensen Arms', model_name='Modern Precision Rifle .308', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='.308 Win', action='BOLT',
             barrel_length_mm=610, status=V),
        dict(brand='Proof Research', model_name='Glacier Ti 6.5CM', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='6.5 Creedmoor', action='BOLT',
             barrel_length_mm=559, status=V),
        dict(brand='Winchester', model_name='XPR .308', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='.308 Win', action='BOLT',
             barrel_length_mm=610, status=V),
        dict(brand='Winchester', model_name='XPR 6.5CM', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='6.5 Creedmoor', action='BOLT',
             barrel_length_mm=610, status=V),
        dict(brand='Mossberg', model_name='MVP Precision .308', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='.308 Win', action='BOLT',
             barrel_length_mm=660, status=V),
        dict(brand='Desert Tech', model_name='SRS A2 .308', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='.308 Win', action='BOLT',
             barrel_length_mm=610, status=V),
        dict(brand='Desert Tech', model_name='SRS A2 6.5CM', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='6.5 Creedmoor', action='BOLT',
             barrel_length_mm=610, status=V),
        dict(brand='Victrix Armaments', model_name='Scorpio T 6.5CM', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='6.5 Creedmoor', action='BOLT',
             barrel_length_mm=660, status=V),
        dict(brand='Victrix Armaments', model_name='Venus .308', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='.308 Win', action='BOLT',
             barrel_length_mm=660, status=V),
        dict(brand='Bergara', model_name='B-14 Squared Crest 6.5CM', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='6.5 Creedmoor', action='BOLT',
             barrel_length_mm=559, status=V),
        dict(brand='Bergara', model_name='Premier HMR Pro 6.5PRC', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='6.5 PRC', action='BOLT',
             barrel_length_mm=610, status=V),
        dict(brand='Tikka', model_name='T3x UPR 6.5CM', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='6.5 Creedmoor', action='BOLT',
             barrel_length_mm=610, status=V),
        dict(brand='Sako', model_name='90 Adventure .308', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='.308 Win', action='BOLT',
             barrel_length_mm=572, status=V),
        dict(brand='Sako', model_name='90 Peak 6.5CM', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='6.5 Creedmoor', action='BOLT',
             barrel_length_mm=560, status=V),
        dict(brand='Accuracy International', model_name='AX308 .308', gear_type='FIREARM',
             firearm_type='RIFLE', caliber='.308 Win', action='BOLT',
             barrel_length_mm=660, status=V),
    ]

    for data in items:
        Firearm.objects.get_or_create(
            brand=data['brand'],
            model_name=data['model_name'],
            defaults=data,
        )


def add_scopes(apps, schema_editor):
    Scope = _get(apps, 'Scope')
    V = 'VERIFIED'

    items = [
        dict(brand='Athlon', model_name='Argos BTR 6-24x50', gear_type='SCOPE',
             magnification_min=6, magnification_max=24, objective_diameter_mm=50,
             tube_diameter_mm=30, reticle_type='MILDOT',
             adjustment_unit='MRAD', focal_plane='FFP', status=V),
        dict(brand='Athlon', model_name='Cronus BTR 4.5-29x56', gear_type='SCOPE',
             magnification_min=4, magnification_max=29, objective_diameter_mm=56,
             tube_diameter_mm=34, reticle_type='MILDOT',
             adjustment_unit='MRAD', focal_plane='FFP', status=V),
        dict(brand='Athlon', model_name='Ares BTR 4.5-27x50 FFP', gear_type='SCOPE',
             magnification_min=4, magnification_max=27, objective_diameter_mm=50,
             tube_diameter_mm=30, reticle_type='MILDOT',
             adjustment_unit='MRAD', focal_plane='FFP', status=V),
        dict(brand='Primary Arms', model_name='PLx 6-30x56 FFP', gear_type='SCOPE',
             magnification_min=6, magnification_max=30, objective_diameter_mm=56,
             tube_diameter_mm=34, reticle_type='MILDOT',
             adjustment_unit='MRAD', focal_plane='FFP', status=V),
        dict(brand='Primary Arms', model_name='SLx 4-16x44 FFP', gear_type='SCOPE',
             magnification_min=4, magnification_max=16, objective_diameter_mm=44,
             tube_diameter_mm=30, reticle_type='MILDOT',
             adjustment_unit='MRAD', focal_plane='FFP', status=V),
        dict(brand='Hawke', model_name='Sidewinder 30 6-24x50 FFP', gear_type='SCOPE',
             magnification_min=6, magnification_max=24, objective_diameter_mm=50,
             tube_diameter_mm=30, reticle_type='MILDOT',
             adjustment_unit='MOA', focal_plane='FFP', status=V),
        dict(brand='Delta Optical', model_name='Stryker HD 4.5-30x56 FFP', gear_type='SCOPE',
             magnification_min=4, magnification_max=30, objective_diameter_mm=56,
             tube_diameter_mm=34, reticle_type='MILDOT',
             adjustment_unit='MRAD', focal_plane='FFP', status=V),
        dict(brand='Kahles', model_name='K525i 5-25x56 FFP', gear_type='SCOPE',
             magnification_min=5, magnification_max=25, objective_diameter_mm=56,
             tube_diameter_mm=34, reticle_type='MILDOT',
             adjustment_unit='MRAD', focal_plane='FFP', status=V),
        dict(brand='March', model_name='FX 8-80x56 FFP', gear_type='SCOPE',
             magnification_min=8, magnification_max=80, objective_diameter_mm=56,
             tube_diameter_mm=34, reticle_type='MILDOT',
             adjustment_unit='MRAD', focal_plane='FFP', status=V),
        dict(brand='March', model_name='Genesis 6-60x56 FFP', gear_type='SCOPE',
             magnification_min=6, magnification_max=60, objective_diameter_mm=56,
             tube_diameter_mm=34, reticle_type='MILDOT',
             adjustment_unit='MRAD', focal_plane='FFP', status=V),
        dict(brand='SIG Sauer', model_name='TANGO6T 1-6x24 FFP', gear_type='SCOPE',
             magnification_min=1, magnification_max=6, objective_diameter_mm=24,
             tube_diameter_mm=30, reticle_type='ILLUMINATED',
             adjustment_unit='MOA', focal_plane='FFP', status=V),
        dict(brand='SIG Sauer', model_name='TANGO4 4-16x44 FFP', gear_type='SCOPE',
             magnification_min=4, magnification_max=16, objective_diameter_mm=44,
             tube_diameter_mm=30, reticle_type='MILDOT',
             adjustment_unit='MOA', focal_plane='FFP', status=V),
        dict(brand='Leupold', model_name='VX-5HD 3-15x44 CDS-TZL3', gear_type='SCOPE',
             magnification_min=3, magnification_max=15, objective_diameter_mm=44,
             tube_diameter_mm=30, reticle_type='DUPLEX',
             adjustment_unit='MOA', focal_plane='SFP', status=V),
        dict(brand='Leupold', model_name='Mark 5HD 5-25x56 M5C3', gear_type='SCOPE',
             magnification_min=5, magnification_max=25, objective_diameter_mm=56,
             tube_diameter_mm=35, reticle_type='MILDOT',
             adjustment_unit='MRAD', focal_plane='FFP', status=V),
        dict(brand='Burris', model_name='XTR III 3.3-18x50 FFP', gear_type='SCOPE',
             magnification_min=3, magnification_max=18, objective_diameter_mm=50,
             tube_diameter_mm=34, reticle_type='MILDOT',
             adjustment_unit='MRAD', focal_plane='FFP', status=V),
        dict(brand='US Optics', model_name='B-25 5-25x52 FFP', gear_type='SCOPE',
             magnification_min=5, magnification_max=25, objective_diameter_mm=52,
             tube_diameter_mm=34, reticle_type='MILDOT',
             adjustment_unit='MRAD', focal_plane='FFP', status=V),
        dict(brand='IOR Valdada', model_name='Terminator 3-18x50 FFP', gear_type='SCOPE',
             magnification_min=3, magnification_max=18, objective_diameter_mm=50,
             tube_diameter_mm=30, reticle_type='MILDOT',
             adjustment_unit='MRAD', focal_plane='FFP', status=V),
        dict(brand='Vortex', model_name='Strike Eagle 5-25x56', gear_type='SCOPE',
             magnification_min=5, magnification_max=25, objective_diameter_mm=56,
             tube_diameter_mm=34, reticle_type='ILLUMINATED',
             adjustment_unit='MOA', focal_plane='FFP', status=V),
        dict(brand='Vortex', model_name='Diamondback Tactical 6-24x50', gear_type='SCOPE',
             magnification_min=6, magnification_max=24, objective_diameter_mm=50,
             tube_diameter_mm=30, reticle_type='ETCHED',
             adjustment_unit='MOA', focal_plane='FFP', status=V),
        dict(brand='Nightforce', model_name='ATACR 7-35x56 F1', gear_type='SCOPE',
             magnification_min=7, magnification_max=35, objective_diameter_mm=56,
             tube_diameter_mm=34, reticle_type='MILDOT',
             adjustment_unit='MRAD', focal_plane='FFP', status=V),
        dict(brand='Nightforce', model_name='NXS 5.5-22x56 F1', gear_type='SCOPE',
             magnification_min=5, magnification_max=22, objective_diameter_mm=56,
             tube_diameter_mm=30, reticle_type='MILDOT',
             adjustment_unit='MRAD', focal_plane='FFP', status=V),
    ]

    for data in items:
        Scope.objects.get_or_create(
            brand=data['brand'],
            model_name=data['model_name'],
            defaults=data,
        )


def add_suppressors(apps, schema_editor):
    Suppressor = _get(apps, 'Suppressor')
    V = 'VERIFIED'

    items = [
        dict(brand='OSS', model_name='HX-QD 556', gear_type='SUPPRESSOR',
             max_caliber='5.56mm NATO', thread_pitch='1/2-28',
             length_mm=170, weight_g=340, status=V),
        dict(brand='Griffin Armament', model_name='Resistance 46M', gear_type='SUPPRESSOR',
             max_caliber='9mm Luger', thread_pitch='1/2-28',
             length_mm=190, weight_g=283, status=V),
        dict(brand='SureFire', model_name='SOCOM556-RC2', gear_type='SUPPRESSOR',
             max_caliber='5.56mm NATO', thread_pitch='1/2-28',
             length_mm=152, weight_g=454, status=V),
        dict(brand='AAC', model_name='SDN-6', gear_type='SUPPRESSOR',
             max_caliber='7.62mm NATO', thread_pitch='5/8-24',
             length_mm=185, weight_g=496, status=V),
        dict(brand='SilencerCo', model_name='Omega 9K', gear_type='SUPPRESSOR',
             max_caliber='9mm Luger', thread_pitch='1/2-28',
             length_mm=127, weight_g=340, status=V),
        dict(brand='Dead Air', model_name='Nomad-L', gear_type='SUPPRESSOR',
             max_caliber='7.62mm NATO', thread_pitch='5/8-24',
             length_mm=216, weight_g=510, status=V),
        dict(brand='Rugged', model_name='Obsidian 9', gear_type='SUPPRESSOR',
             max_caliber='9mm Luger', thread_pitch='1/2-28',
             length_mm=203, weight_g=425, status=V),
        dict(brand='Gemtech', model_name='G5-T 7.62', gear_type='SUPPRESSOR',
             max_caliber='7.62mm NATO', thread_pitch='5/8-24',
             length_mm=191, weight_g=510, status=V),
        dict(brand='B&T', model_name='Rotex-V 7.62', gear_type='SUPPRESSOR',
             max_caliber='7.62mm NATO', thread_pitch='5/8-24',
             length_mm=220, weight_g=640, status=V),
    ]

    for data in items:
        Suppressor.objects.get_or_create(
            brand=data['brand'],
            model_name=data['model_name'],
            defaults=data,
        )


def add_bipods(apps, schema_editor):
    Bipod = _get(apps, 'Bipod')
    V = 'VERIFIED'

    items = [
        dict(brand='Caldwell', model_name='XLA 9-13"', gear_type='BIPOD',
             min_height_mm=229, max_height_mm=330,
             attachment_type='Picatinny', status=V),
        dict(brand='RRS', model_name='SOAR B2 Arca', gear_type='BIPOD',
             min_height_mm=177, max_height_mm=330,
             attachment_type='Arca-Swiss/Picatinny', status=V),
        dict(brand='Trigger-Tech', model_name='Diamond Bipod', gear_type='BIPOD',
             min_height_mm=152, max_height_mm=280,
             attachment_type='Picatinny', status=V),
        dict(brand='Spartan Precision', model_name='Javelin Lite', gear_type='BIPOD',
             min_height_mm=178, max_height_mm=330,
             attachment_type='Sling stud/Picatinny', status=V),
        dict(brand='Fortmeier', model_name='H-POD', gear_type='BIPOD',
             min_height_mm=200, max_height_mm=380,
             attachment_type='Picatinny', status=V),
    ]

    for data in items:
        Bipod.objects.get_or_create(
            brand=data['brand'],
            model_name=data['model_name'],
            defaults=data,
        )


def add_magazines(apps, schema_editor):
    Magazine = _get(apps, 'Magazine')
    V = 'VERIFIED'

    items = [
        dict(brand='Glock', model_name='G17 Factory 17rd', gear_type='MAGAZINE',
             caliber='9mm Luger', capacity=17, status=V),
        dict(brand='Glock', model_name='G17 Factory 33rd', gear_type='MAGAZINE',
             caliber='9mm Luger', capacity=33, status=V),
        dict(brand='Glock', model_name='G19 Factory 15rd', gear_type='MAGAZINE',
             caliber='9mm Luger', capacity=15, status=V),
        dict(brand='SIG Sauer', model_name='P320 Factory 17rd', gear_type='MAGAZINE',
             caliber='9mm Luger', capacity=17, status=V),
        dict(brand='SIG Sauer', model_name='P320 Factory 21rd', gear_type='MAGAZINE',
             caliber='9mm Luger', capacity=21, status=V),
        dict(brand='CZ', model_name='Shadow 2 Factory 17rd', gear_type='MAGAZINE',
             caliber='9mm Luger', capacity=17, status=V),
        dict(brand='HK', model_name='VP9 Factory 15rd', gear_type='MAGAZINE',
             caliber='9mm Luger', capacity=15, status=V),
        dict(brand='Beretta', model_name='92FS Factory 15rd', gear_type='MAGAZINE',
             caliber='9mm Luger', capacity=15, status=V),
        dict(brand='Magpul', model_name='PMAG 10 AR/M4 Gen M3', gear_type='MAGAZINE',
             caliber='5.56x45mm NATO', capacity=10, status=V),
        dict(brand='Magpul', model_name='PMAG D-60 AR/M4', gear_type='MAGAZINE',
             caliber='5.56x45mm NATO', capacity=60, status=V),
        dict(brand='Ruger', model_name='BX-25 10/22', gear_type='MAGAZINE',
             caliber='.22 LR', capacity=25, status=V),
        dict(brand='Ruger', model_name='BX-1 10/22', gear_type='MAGAZINE',
             caliber='.22 LR', capacity=10, status=V),
        dict(brand='CZ', model_name='457 Factory 5rd', gear_type='MAGAZINE',
             caliber='.22 LR', capacity=5, status=V),
        dict(brand='CZ', model_name='457 Factory 10rd', gear_type='MAGAZINE',
             caliber='.22 LR', capacity=10, status=V),
        dict(brand='Magpul', model_name='PMAG 20 GL9 (Glock 17)', gear_type='MAGAZINE',
             caliber='9mm Luger', capacity=20, status=V),
    ]

    for data in items:
        Magazine.objects.get_or_create(
            brand=data['brand'],
            model_name=data['model_name'],
            caliber=data.get('caliber', ''),
            defaults=data,
        )


class Migration(migrations.Migration):

    dependencies = [
        ('gears', '0007_scope_optics'),
    ]

    operations = [
        migrations.RunPython(add_firearms,    migrations.RunPython.noop),
        migrations.RunPython(add_scopes,      migrations.RunPython.noop),
        migrations.RunPython(add_suppressors, migrations.RunPython.noop),
        migrations.RunPython(add_bipods,      migrations.RunPython.noop),
        migrations.RunPython(add_magazines,   migrations.RunPython.noop),
    ]
