0

I have 6 models, three of 2 types. The types being private and public, but, in this case, all the models have the same fields.

class AbstractModel(models.Model):
    text = models.CharField(max_length = 1)
    in_group = models.ForeignKey(GroupTable, on_delete=models.SET_NULL, null=True)
    class Meta:
        abstract = True
class Public1(AbstractModel):
    pass
class Public2(AbstractModel):
    pass
class Public3(AbstractModel):
    pass
class Priv1(AbstractModel):
    pass
class Priv2(AbstractModel):
    pass
class Priv3(AbstractModel):
    pass

class GroupTable(models.Model):
    private = models.BooleanField(default=True)
post_save.connect(herd_migration, sender=DecidingTable)

Ok, so with these models, time for signals.py. I'm trying to transfer all the charfields from Public to Priv tables, and Public1 data goes to Priv1, Public2 to Priv2, and Public3 to Priv3. The problem is mostly user end:

The models are designed like a nested hierarchy path for specific design purposes. When a group switches the attribute private to False, the signal is "sent" to start data transferring of all records in Priv1-3 that are in that specific group to Public1-3.

I was thinking of these two options:

1) Temporarily shutdown the group so that no more POST reqs are sent that corresponds to the group and quickly transfer all Priv1 data to Public1, Priv2 to Public2, and Priv3 to Public3.

2) Add a table that's kinda like a queue to add to public tables. But then would users make a POST req to Priv tables or to the queue table?

Maybe raw sql in Postgres?

Any suggestions?

Edit:

Another idea would be to copy all the Priv1 records first, then the Priv2, then Priv3. Again these tables are in a hierarchy

  • What's the point of this? Why all the separate tables rather than for example a single table with a type field? – Daniel Roseman Jun 21 '19 at 07:01
  • @DanielRoseman Each table has a comments table linked to it. The comments table is also a hierarchy. If I only has two tables for each pub and priv, then I thought the entire thing would be messy and inefficient, especially when it comes to indexing. –  Jun 21 '19 at 11:58

0 Answers0