Skip to content

Commit

Permalink
Feat: Add created_at, created_at to workspace_schedule and workspaces… (
Browse files Browse the repository at this point in the history
#688)

* Feat: Add created_at, created_at to workspace_schedule and workspaces_user table

* changing model

* fixed issue

* sql fixture fixed

* removed migration changes

* remove migrations
  • Loading branch information
Ashutosh619-sudo authored Dec 23, 2024
1 parent 5887335 commit af802ea
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 11 deletions.
3 changes: 2 additions & 1 deletion apps/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
BaseUserManager, AbstractBaseUser
)


class User(AbstractBaseUser):
id = models.AutoField(primary_key=True)
email = models.EmailField(
Expand All @@ -21,3 +20,5 @@ class User(AbstractBaseUser):

class Meta:
db_table = 'users'


34 changes: 34 additions & 0 deletions apps/workspaces/migrations/0042_auto_20241219_1808.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Generated by Django 3.2.14 on 2024-12-19 18:08

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('workspaces', '0041_configuration_is_attachment_upload_enabled'),
]

operations = [
migrations.AddField(
model_name='workspaceschedule',
name='created_at',
field=models.DateTimeField(auto_now_add=True, help_text='Created at datetime', null=True),
),
migrations.AddField(
model_name='workspaceschedule',
name='updated_at',
field=models.DateTimeField(auto_now=True, help_text='Updated at datetime', null=True),
),
migrations.RunSQL(
sql="""
ALTER TABLE workspaces_user
ADD COLUMN created_at TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT NOW();
""",
reverse_sql="""
ALTER TABLE workspaces_user
DROP COLUMN created_at;
""",
),

]
2 changes: 2 additions & 0 deletions apps/workspaces/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ class WorkspaceSchedule(models.Model):
additional_email_options = JSONField(default=list, help_text='Email and Name of person to send email', null=True)
emails_selected = ArrayField(base_field=models.CharField(max_length=255), null=True, help_text='File IDs')
schedule = models.OneToOneField(Schedule, on_delete=models.PROTECT, null=True)
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 = 'workspace_schedules'
Expand Down
22 changes: 13 additions & 9 deletions tests/sql_fixtures/reset_db_fixtures/reset_db.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1932,7 +1932,9 @@ CREATE TABLE public.workspace_schedules (
schedule_id integer,
additional_email_options jsonb,
emails_selected character varying(255)[],
error_count integer
error_count integer,
created_at timestamp with time zone,
updated_at timestamp with time zone
);


Expand Down Expand Up @@ -2012,7 +2014,8 @@ ALTER SEQUENCE public.workspaces_netsuitecredentials_id_seq OWNED BY public.nets
CREATE TABLE public.workspaces_user (
id integer NOT NULL,
workspace_id integer NOT NULL,
user_id integer NOT NULL
user_id integer NOT NULL,
created_at timestamp with time zone DEFAULT now() NOT NULL
);


Expand Down Expand Up @@ -8000,6 +8003,7 @@ COPY public.django_migrations (id, app, name, applied) FROM stdin;
206 fyle 0036_expense_masked_corporate_card_number 2024-11-26 09:24:50.240658+00
207 fyle_accounting_mappings 0027_alter_employeemapping_source_employee 2024-12-18 05:34:34.929303+00
208 workspaces 0041_configuration_is_attachment_upload_enabled 2024-12-18 05:34:34.968096+00
209 workspaces 0042_auto_20241219_1808 2024-12-23 09:56:48.057086+00
\.


Expand Down Expand Up @@ -11803,8 +11807,8 @@ COPY public.vendor_payments (id, accounts_payable_id, account_id, entity_id, cur
-- Data for Name: workspace_schedules; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.workspace_schedules (id, enabled, start_datetime, interval_hours, workspace_id, schedule_id, additional_email_options, emails_selected, error_count) FROM stdin;
1 t 2022-05-10 11:54:10.795285+00 1 49 \N \N {[email protected]} \N
COPY public.workspace_schedules (id, enabled, start_datetime, interval_hours, workspace_id, schedule_id, additional_email_options, emails_selected, error_count, created_at, updated_at) FROM stdin;
1 t 2022-05-10 11:54:10.795285+00 1 49 \N \N {[email protected]} \N 2024-12-23 09:56:48.04448+00 2024-12-23 09:56:48.055509+00
\.


Expand All @@ -11823,10 +11827,10 @@ COPY public.workspaces (id, name, fyle_org_id, ns_account_id, last_synced_at, cr
-- Data for Name: workspaces_user; Type: TABLE DATA; Schema: public; Owner: postgres
--

COPY public.workspaces_user (id, workspace_id, user_id) FROM stdin;
1 1 1
2 2 1
66 49 30
COPY public.workspaces_user (id, workspace_id, user_id, created_at) FROM stdin;
1 1 1 2024-12-23 09:56:48.044698+00
2 2 1 2024-12-23 09:56:48.044698+00
66 49 30 2024-12-23 09:56:48.044698+00
\.


Expand Down Expand Up @@ -11911,7 +11915,7 @@ SELECT pg_catalog.setval('public.django_content_type_id_seq', 47, true);
-- Name: django_migrations_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres
--

SELECT pg_catalog.setval('public.django_migrations_id_seq', 208, true);
SELECT pg_catalog.setval('public.django_migrations_id_seq', 209, true);


--
Expand Down
4 changes: 3 additions & 1 deletion tests/test_workspaces/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@
"schedule": null,
"additional_email_options": [],
"emails_selected": null,
"error_count": null
"error_count": null,
"created_at": "2021-11-10T20:41:37.151696Z",
"updated_at": "2021-11-10T20:41:37.151696Z"
}
}

0 comments on commit af802ea

Please sign in to comment.