Skip to content

Commit

Permalink
[db] Remove db_column. Refs #736
Browse files Browse the repository at this point in the history
for fields which are not AutoField
  • Loading branch information
atodorov committed Jan 20, 2020
1 parent 7b1b62a commit 3cf9b65
Show file tree
Hide file tree
Showing 8 changed files with 114 additions and 11 deletions.
28 changes: 28 additions & 0 deletions tcms/management/migrations/0007_remove_auto_field.py
@@ -1,5 +1,6 @@
# Generated by Django 3.0.2 on 2020-01-20 16:48

from django.conf import settings
from django.db import migrations, models


Expand All @@ -10,6 +11,11 @@ class Migration(migrations.Migration):
]

operations = [
migrations.AlterField(
model_name='build',
name='is_active',
field=models.BooleanField(default=True),
),
migrations.AlterField(
model_name='classification',
name='id',
Expand All @@ -22,18 +28,40 @@ class Migration(migrations.Migration):
field=models.AutoField(auto_created=True, primary_key=True,
serialize=False, verbose_name='ID'),
),
migrations.AlterField(
model_name='component',
name='initial_owner',
field=models.ForeignKey(null=True, on_delete=models.deletion.CASCADE,
related_name='initial_owner', to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='component',
name='initial_qa_contact',
field=models.ForeignKey(blank=True, null=True, on_delete=models.deletion.CASCADE,
related_name='initial_qa_contact', to=settings.AUTH_USER_MODEL),
),
migrations.AlterField(
model_name='priority',
name='id',
field=models.AutoField(auto_created=True, primary_key=True,
serialize=False, verbose_name='ID'),
),
migrations.AlterField(
model_name='priority',
name='is_active',
field=models.BooleanField(default=True),
),
migrations.AlterField(
model_name='product',
name='id',
field=models.AutoField(auto_created=True, primary_key=True,
serialize=False, verbose_name='ID'),
),
migrations.AlterField(
model_name='tag',
name='name',
field=models.CharField(max_length=255),
),
migrations.AlterField(
model_name='version',
name='id',
Expand Down
12 changes: 5 additions & 7 deletions tcms/management/models.py
Expand Up @@ -50,7 +50,7 @@ class Meta:

class Priority(TCMSActionModel):
value = models.CharField(unique=True, max_length=64)
is_active = models.BooleanField(db_column='isactive', default=True)
is_active = models.BooleanField(default=True)

class Meta:
ordering = ['value']
Expand All @@ -65,15 +65,13 @@ class Component(TCMSActionModel):
product = models.ForeignKey(Product, related_name='component', on_delete=models.CASCADE)
initial_owner = models.ForeignKey(
settings.AUTH_USER_MODEL,
db_column='initialowner',
related_name='initialowner',
related_name='initial_owner',
null=True,
on_delete=models.CASCADE
)
initial_qa_contact = models.ForeignKey(
settings.AUTH_USER_MODEL,
db_column='initialqacontact',
related_name='initialqacontact',
related_name='initial_qa_contact',
blank=True,
null=True,
on_delete=models.CASCADE
Expand Down Expand Up @@ -115,7 +113,7 @@ class Build(TCMSActionModel):
build_id = models.AutoField(unique=True, primary_key=True)
name = models.CharField(max_length=255)
product = models.ForeignKey(Product, related_name='build', on_delete=models.CASCADE)
is_active = models.BooleanField(db_column='isactive', default=True)
is_active = models.BooleanField(default=True)

class Meta:
ordering = ['name']
Expand All @@ -136,7 +134,7 @@ def __str__(self):

class Tag(TCMSActionModel):
id = models.AutoField(db_column='tag_id', primary_key=True)
name = models.CharField(db_column='tag_name', max_length=255)
name = models.CharField(max_length=255)

class Meta:
ordering = ['name']
Expand Down
23 changes: 23 additions & 0 deletions tcms/testcases/migrations/0013_remove_db_column.py
@@ -0,0 +1,23 @@
# Generated by Django 3.0.2 on 2020-01-20 19:47

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('testcases', '0012_remove_autofield_max_length'),
]

operations = [
migrations.AlterField(
model_name='historicaltestcase',
name='create_date',
field=models.DateTimeField(blank=True, editable=False),
),
migrations.AlterField(
model_name='testcase',
name='create_date',
field=models.DateTimeField(auto_now_add=True),
),
]
2 changes: 1 addition & 1 deletion tcms/testcases/models.py
Expand Up @@ -71,7 +71,7 @@ class TestCase(TCMSActionModel):
history = KiwiHistoricalRecords()

case_id = models.AutoField(primary_key=True)
create_date = models.DateTimeField(db_column='creation_date', auto_now_add=True)
create_date = models.DateTimeField(auto_now_add=True)
is_automated = models.BooleanField(default=False)
script = models.TextField(blank=True, null=True)
arguments = models.TextField(blank=True, null=True)
Expand Down
33 changes: 33 additions & 0 deletions tcms/testplans/migrations/0008_remove_db_column.py
@@ -0,0 +1,33 @@
# Generated by Django 3.0.2 on 2020-01-20 19:47

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('testplans', '0007_notifications_default_true'),
]

operations = [
migrations.AlterField(
model_name='historicaltestplan',
name='create_date',
field=models.DateTimeField(blank=True, editable=False),
),
migrations.AlterField(
model_name='historicaltestplan',
name='is_active',
field=models.BooleanField(db_index=True, default=True),
),
migrations.AlterField(
model_name='testplan',
name='create_date',
field=models.DateTimeField(auto_now_add=True),
),
migrations.AlterField(
model_name='testplan',
name='is_active',
field=models.BooleanField(db_index=True, default=True),
),
]
4 changes: 2 additions & 2 deletions tcms/testplans/models.py
Expand Up @@ -38,8 +38,8 @@ class TestPlan(TCMSActionModel):
plan_id = models.AutoField(primary_key=True)
name = models.CharField(max_length=255, db_index=True)
text = models.TextField(blank=True)
create_date = models.DateTimeField(db_column='creation_date', auto_now_add=True)
is_active = models.BooleanField(db_column='isactive', default=True, db_index=True)
create_date = models.DateTimeField(auto_now_add=True)
is_active = models.BooleanField(default=True, db_index=True)
extra_link = models.CharField(max_length=1024, default=None, blank=True, null=True)

product_version = models.ForeignKey(Version, related_name='plans', on_delete=models.CASCADE)
Expand Down
21 changes: 21 additions & 0 deletions tcms/testruns/migrations/0008_remove_db_column.py
@@ -0,0 +1,21 @@
# Generated by Django 3.0.2 on 2020-01-20 19:58

from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('testruns', '0007_test_execution_statuses'),
]

operations = [
migrations.AlterField(
model_name='testruncc',
name='user',
field=models.ForeignKey(on_delete=models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL),
),
]
2 changes: 1 addition & 1 deletion tcms/testruns/models.py
Expand Up @@ -319,7 +319,7 @@ class TestRunTag(models.Model):

class TestRunCC(models.Model):
run = models.ForeignKey(TestRun, related_name='cc_list', on_delete=models.CASCADE)
user = models.ForeignKey(settings.AUTH_USER_MODEL, db_column='who', on_delete=models.CASCADE)
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE)

class Meta:
unique_together = ('run', 'user')

0 comments on commit 3cf9b65

Please sign in to comment.