Skip to content

Commit

Permalink
Fix: Add created_at, created_at to workspace_schedule and workspaces_…
Browse files Browse the repository at this point in the history
…user table
  • Loading branch information
Ashutosh619-sudo committed Dec 19, 2024
1 parent 5abc8e8 commit 418fea2
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 2 deletions.
19 changes: 18 additions & 1 deletion apps/workspaces/migrations/0001_initial.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.conf import settings
from django.db import migrations, models
import ms_business_central_api.models.fields
import django.db.models.deletion


class Migration(migrations.Migration):
Expand Down Expand Up @@ -31,10 +32,26 @@ class Migration(migrations.Migration):
('business_central_company_id', ms_business_central_api.models.fields.StringNullField(help_text='Business Central Company Id', max_length=255, null=True)),
('created_at', models.DateTimeField(auto_now_add=True, help_text='Created at datetime')),
('updated_at', models.DateTimeField(auto_now=True, help_text='Updated at datetime')),
('user', models.ManyToManyField(help_text='Reference to users table', to=settings.AUTH_USER_MODEL)),
],
options={
'db_table': 'workspaces',
},
),
migrations.CreateModel(
name='WorkspacesUser',
fields=[
('id', models.BigAutoField(primary_key=True, serialize=False)),
('user', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to=settings.AUTH_USER_MODEL)),
('workspace', models.ForeignKey(on_delete=django.db.models.deletion.DO_NOTHING, to='workspaces.workspace')),
],
options={
'db_table': 'workspaces_user',
'unique_together': {('workspace', 'user')},
},
),
migrations.AlterField(
model_name='workspace',
name='user',
field=models.ManyToManyField(help_text='Reference to users table', through='workspaces.WorkspacesUser', to=settings.AUTH_USER_MODEL),
),
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Generated by Django 4.1.2 on 2024-12-19 18:26

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('workspaces', '0006_rename_default_ccc_bank_account_id_exportsetting_default_ccc_bank_account_id_and_more'),
]

operations = [
migrations.AddField(
model_name='workspacesuser',
name='created_at',
field=models.DateTimeField(auto_now_add=True, help_text='Created at datetime', null=True),
),
migrations.AddField(
model_name='workspacesuser',
name='updated_at',
field=models.DateTimeField(auto_now=True, help_text='Updated at datetime', null=True),
),
]
12 changes: 11 additions & 1 deletion apps/workspaces/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,24 @@
def get_default_onboarding_state():
return 'CONNECTION'

class WorkspacesUser(models.Model):
id = models.BigAutoField(primary_key=True)
workspace = models.ForeignKey('Workspace', models.DO_NOTHING)
user = models.ForeignKey('users.User', models.DO_NOTHING)
created_at = models.DateTimeField(auto_now_add=True, null=True, help_text='Created at datetime')
updated_at = models.DateTimeField(auto_now=True, null=True, help_text='Updated at datetime')

class Meta:
db_table = 'workspaces_user'
unique_together = (('workspace', 'user'),)

class Workspace(models.Model):
"""
Workspace model
"""
id = models.AutoField(primary_key=True)
name = StringNotNullField(help_text='Name of the workspace')
user = models.ManyToManyField(User, help_text='Reference to users table')
user = models.ManyToManyField(User, help_text='Reference to users table', through='WorkspacesUser')
org_id = models.CharField(max_length=255, help_text='org id', unique=True)
reimbursable_last_synced_at = CustomDateTimeField(help_text='Datetime when expenses were pulled last')
credit_card_last_synced_at = CustomDateTimeField(help_text='Datetime when ccc expenses were pulled last')
Expand Down

0 comments on commit 418fea2

Please sign in to comment.