Skip to content

Commit

Permalink
Merge pull request #2648 from phillxnet/2645-Establish-on_delete-for-…
Browse files Browse the repository at this point in the history
…ForeignKey-re-Django-update

Establish on_delete for ForeignKey re Django update #2645
  • Loading branch information
phillxnet authored Aug 14, 2023
2 parents 7957f8a + b003f50 commit f6d51fa
Show file tree
Hide file tree
Showing 34 changed files with 363 additions and 112 deletions.
18 changes: 9 additions & 9 deletions src/rockstor/smart_manager/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ class Migration(migrations.Migration):
('end_ts', models.DateTimeField(null=True, db_index=True)),
('status', models.CharField(max_length=10)),
('error', models.CharField(max_length=4096, null=True)),
('replica', models.ForeignKey(to='smart_manager.Replica')),
('replica', models.ForeignKey(to='smart_manager.Replica', on_delete=models.CASCADE)),
],
),
migrations.CreateModel(
Expand All @@ -267,7 +267,7 @@ class Migration(migrations.Migration):
('status', models.BooleanField(default=False)),
('count', models.BigIntegerField(default=1)),
('ts', models.DateTimeField(auto_now=True, db_index=True)),
('service', models.ForeignKey(to='smart_manager.Service')),
('service', models.ForeignKey(to='smart_manager.Service', on_delete=models.CASCADE)),
],
),
migrations.CreateModel(
Expand Down Expand Up @@ -325,36 +325,36 @@ class Migration(migrations.Migration):
migrations.AddField(
model_name='task',
name='task_def',
field=models.ForeignKey(to='smart_manager.TaskDefinition'),
field=models.ForeignKey(to='smart_manager.TaskDefinition', on_delete=models.CASCADE),
),
migrations.AddField(
model_name='receivetrail',
name='rshare',
field=models.ForeignKey(to='smart_manager.ReplicaShare'),
field=models.ForeignKey(to='smart_manager.ReplicaShare', on_delete=models.CASCADE),
),
migrations.AddField(
model_name='nfsduidgiddistribution',
name='rid',
field=models.ForeignKey(to='smart_manager.SProbe'),
field=models.ForeignKey(to='smart_manager.SProbe', on_delete=models.CASCADE),
),
migrations.AddField(
model_name='nfsdsharedistribution',
name='rid',
field=models.ForeignKey(to='smart_manager.SProbe'),
field=models.ForeignKey(to='smart_manager.SProbe', on_delete=models.CASCADE),
),
migrations.AddField(
model_name='nfsdshareclientdistribution',
name='rid',
field=models.ForeignKey(to='smart_manager.SProbe'),
field=models.ForeignKey(to='smart_manager.SProbe', on_delete=models.CASCADE),
),
migrations.AddField(
model_name='nfsdclientdistribution',
name='rid',
field=models.ForeignKey(to='smart_manager.SProbe'),
field=models.ForeignKey(to='smart_manager.SProbe', on_delete=models.CASCADE),
),
migrations.AddField(
model_name='nfsdcalldistribution',
name='rid',
field=models.ForeignKey(to='smart_manager.SProbe'),
field=models.ForeignKey(to='smart_manager.SProbe', on_delete=models.CASCADE),
),
]
25 changes: 25 additions & 0 deletions src/rockstor/smart_manager/migrations/0003_auto_20230810_1143.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.29 on 2023-08-10 10:43
from __future__ import unicode_literals

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('smart_manager', '0002_auto_20170216_1212'),
]

operations = [
migrations.AlterField(
model_name='sprobe',
name='state',
field=models.CharField(choices=[('created', 'created'), ('error', 'error'), ('running', 'running'), ('stopped', 'stopped')], max_length=7),
),
migrations.AlterField(
model_name='taskdefinition',
name='task_type',
field=models.CharField(choices=[('scrub', 'scrub'), ('snapshot', 'snapshot'), ('reboot', 'reboot'), ('shutdown', 'shutdown'), ('suspend', 'suspend'), ('custom', 'custom')], max_length=100),
),
]
4 changes: 2 additions & 2 deletions src/rockstor/smart_manager/models/nfsd.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class NFSDCallDistribution(models.Model):
for a given ts, number and i/o size of various nfs calls
"""

rid = models.ForeignKey(SProbe)
rid = models.ForeignKey(SProbe, on_delete=models.CASCADE)
ts = models.DateTimeField(db_index=True)
num_lookup = models.BigIntegerField(default=0)
num_read = models.BigIntegerField(default=0)
Expand All @@ -51,7 +51,7 @@ class NFSDClientDistribution(models.Model):
for a given ts and client_ip, number and i/o size of various nfs calls
"""

rid = models.ForeignKey(SProbe)
rid = models.ForeignKey(SProbe, on_delete=models.CASCADE)
ts = models.DateTimeField()
ip = models.CharField(max_length=15)
num_lookup = models.BigIntegerField(default=0)
Expand Down
2 changes: 1 addition & 1 deletion src/rockstor/smart_manager/models/nfsd_share.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class NFSDShareDistribution(models.Model):
for a given ts and share, number and i/o size of various nfs calls
"""

rid = models.ForeignKey(SProbe)
rid = models.ForeignKey(SProbe, on_delete=models.CASCADE)
ts = models.DateTimeField(db_index=True)
share = models.CharField(max_length=255)
num_lookup = models.BigIntegerField(default=0)
Expand Down
2 changes: 1 addition & 1 deletion src/rockstor/smart_manager/models/nfsd_share_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class NFSDShareClientDistribution(models.Model):
for a given ts and share, number and i/o size of various nfs calls
"""

rid = models.ForeignKey(SProbe)
rid = models.ForeignKey(SProbe, on_delete=models.CASCADE)
ts = models.DateTimeField(db_index=True)
share = models.CharField(max_length=255)
client = models.CharField(max_length=100)
Expand Down
2 changes: 1 addition & 1 deletion src/rockstor/smart_manager/models/nfsd_uid_gid.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class NFSDUidGidDistribution(models.Model):
for a given ts and share, number and i/o size of various nfs calls
"""

rid = models.ForeignKey(SProbe)
rid = models.ForeignKey(SProbe, on_delete=models.CASCADE)
ts = models.DateTimeField(db_index=True)
share = models.CharField(max_length=255)
client = models.CharField(max_length=100)
Expand Down
2 changes: 1 addition & 1 deletion src/rockstor/smart_manager/models/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class Meta:

class ServiceStatus(models.Model):

service = models.ForeignKey(Service)
service = models.ForeignKey(Service, on_delete=models.CASCADE)
status = models.BooleanField(default=False)
count = models.BigIntegerField(default=1)
ts = models.DateTimeField(auto_now=True, db_index=True)
Expand Down
4 changes: 2 additions & 2 deletions src/rockstor/smart_manager/models/share_replication.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class ReplicaTrail(models.Model):
3. snapshot_created -> send_pending -> send_failed (error)
"""

replica = models.ForeignKey(Replica)
replica = models.ForeignKey(Replica, on_delete=models.CASCADE)
snap_name = models.CharField(max_length=1024)
kb_sent = models.BigIntegerField(default=0)
snapshot_created = models.DateTimeField(null=True)
Expand Down Expand Up @@ -92,7 +92,7 @@ class ReceiveTrail(models.Model):
3. snapshot_created -> send_pending -> send_failed (error)
"""

rshare = models.ForeignKey(ReplicaShare)
rshare = models.ForeignKey(ReplicaShare, on_delete=models.CASCADE)
snap_name = models.CharField(max_length=1024)
kb_received = models.BigIntegerField(default=0)
receive_pending = models.DateTimeField(null=True)
Expand Down
2 changes: 1 addition & 1 deletion src/rockstor/smart_manager/models/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

class Task(models.Model):

task_def = models.ForeignKey(TaskDefinition)
task_def = models.ForeignKey(TaskDefinition, on_delete=models.CASCADE)
state = models.CharField(max_length=64)
start = models.DateTimeField(null=True, db_index=True)
end = models.DateTimeField(null=True, db_index=True)
Expand Down
Loading

0 comments on commit f6d51fa

Please sign in to comment.