-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: Add created_at, created_at to workspace_schedule and workspaces… #585
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Generated by Django 3.2.14 on 2024-12-23 10:50 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('workspaces', '0039_alter_configuration_change_accounting_period'), | ||
] | ||
|
||
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; | ||
""", | ||
), | ||
] |
Original file line number | Diff line number | Diff line change | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -2,8 +2,8 @@ | |||||||||||||
-- PostgreSQL database dump | ||||||||||||||
-- | ||||||||||||||
|
||||||||||||||
-- Dumped from database version 15.9 (Debian 15.9-1.pgdg120+1) | ||||||||||||||
-- Dumped by pg_dump version 15.8 (Debian 15.8-1.pgdg120+1) | ||||||||||||||
-- Dumped from database version 15.10 (Debian 15.10-1.pgdg120+1) | ||||||||||||||
-- Dumped by pg_dump version 15.10 (Debian 15.10-1.pgdg120+1) | ||||||||||||||
|
||||||||||||||
SET statement_timeout = 0; | ||||||||||||||
SET lock_timeout = 0; | ||||||||||||||
|
@@ -2059,7 +2059,9 @@ CREATE TABLE public.workspace_schedules ( | |||||||||||||
workspace_id integer NOT NULL, | ||||||||||||||
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 | ||||||||||||||
Comment on lines
+2062
to
+2064
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Consider adding NOT NULL constraints and default values The new timestamp columns lack NOT NULL constraints and default values. This could lead to inconsistent data tracking. Consider modifying the columns as follows: - created_at timestamp with time zone,
- updated_at timestamp with time zone
+ created_at timestamp with time zone DEFAULT now() NOT NULL,
+ updated_at timestamp with time zone DEFAULT now() NOT NULL 📝 Committable suggestion
Suggested change
|
||||||||||||||
); | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
|
@@ -2160,7 +2162,8 @@ ALTER SEQUENCE public.workspaces_sageintacctcredential_id_seq OWNED BY public.sa | |||||||||||||
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 | ||||||||||||||
); | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
|
@@ -4137,6 +4140,8 @@ COPY public.django_migrations (id, app, name, applied) FROM stdin; | |||||||||||||
198 tasks 0010_alter_tasklog_expense_group 2024-11-18 04:59:52.206781+00 | ||||||||||||||
199 workspaces 0039_alter_configuration_change_accounting_period 2024-11-18 05:05:10.975057+00 | ||||||||||||||
200 fyle 0035_expense_masked_corporate_card_number 2024-11-20 02:49:32.481921+00 | ||||||||||||||
201 fyle_accounting_mappings 0027_alter_employeemapping_source_employee 2024-12-23 10:52:45.346752+00 | ||||||||||||||
202 workspaces 0040_auto_20241223_1050 2024-12-23 10:52:45.388875+00 | ||||||||||||||
\. | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
|
@@ -8048,7 +8053,7 @@ COPY public.users (password, last_login, id, email, user_id, full_name, active, | |||||||||||||
-- Data for Name: workspace_schedules; Type: TABLE DATA; Schema: public; Owner: postgres | ||||||||||||||
-- | ||||||||||||||
|
||||||||||||||
COPY public.workspace_schedules (id, enabled, start_datetime, interval_hours, schedule_id, workspace_id, additional_email_options, emails_selected, error_count) FROM stdin; | ||||||||||||||
COPY public.workspace_schedules (id, enabled, start_datetime, interval_hours, schedule_id, workspace_id, additional_email_options, emails_selected, error_count, created_at, updated_at) FROM stdin; | ||||||||||||||
\. | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
|
@@ -8065,8 +8070,8 @@ COPY public.workspaces (id, name, fyle_org_id, last_synced_at, created_at, updat | |||||||||||||
-- 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 | ||||||||||||||
COPY public.workspaces_user (id, workspace_id, user_id, created_at) FROM stdin; | ||||||||||||||
1 1 1 2024-12-23 10:52:45.370215+00 | ||||||||||||||
\. | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
|
@@ -8144,7 +8149,7 @@ SELECT pg_catalog.setval('public.django_content_type_id_seq', 50, true); | |||||||||||||
-- Name: django_migrations_id_seq; Type: SEQUENCE SET; Schema: public; Owner: postgres | ||||||||||||||
-- | ||||||||||||||
|
||||||||||||||
SELECT pg_catalog.setval('public.django_migrations_id_seq', 200, true); | ||||||||||||||
SELECT pg_catalog.setval('public.django_migrations_id_seq', 202, true); | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
-- | ||||||||||||||
|
@@ -8620,6 +8625,14 @@ ALTER TABLE ONLY public.employee_mappings | |||||||||||||
ADD CONSTRAINT employee_mappings_pkey PRIMARY KEY (id); | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
-- | ||||||||||||||
-- Name: employee_mappings employee_mappings_source_employee_id_dd9948ba_uniq; Type: CONSTRAINT; Schema: public; Owner: postgres | ||||||||||||||
-- | ||||||||||||||
|
||||||||||||||
ALTER TABLE ONLY public.employee_mappings | ||||||||||||||
ADD CONSTRAINT employee_mappings_source_employee_id_dd9948ba_uniq UNIQUE (source_employee_id); | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
-- | ||||||||||||||
-- Name: errors errors_expense_attribute_id_key; Type: CONSTRAINT; Schema: public; Owner: postgres | ||||||||||||||
-- | ||||||||||||||
|
@@ -9340,13 +9353,6 @@ CREATE INDEX employee_mappings_destination_employee_id_b6764819 ON public.employ | |||||||||||||
CREATE INDEX employee_mappings_destination_vendor_id_c4bd73df ON public.employee_mappings USING btree (destination_vendor_id); | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
-- | ||||||||||||||
-- Name: employee_mappings_source_employee_id_dd9948ba; Type: INDEX; Schema: public; Owner: postgres | ||||||||||||||
-- | ||||||||||||||
|
||||||||||||||
CREATE INDEX employee_mappings_source_employee_id_dd9948ba ON public.employee_mappings USING btree (source_employee_id); | ||||||||||||||
|
||||||||||||||
|
||||||||||||||
-- | ||||||||||||||
-- Name: employee_mappings_workspace_id_4a25f8c9; Type: INDEX; Schema: public; Owner: postgres | ||||||||||||||
-- | ||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,5 +66,5 @@ | |
'masked_corporate_card_number': '**** 4567' | ||
} | ||
], | ||
'workspace_schedule': {'id': 1, 'enabled': True, 'start_datetime': '2022-09-26T13:08:16.281604Z', 'interval_hours': 1, 'error_count': None, 'additional_email_options': [], 'emails_selected': ['[email protected]'], 'workspace': 1, 'schedule': 9} | ||
'workspace_schedule': {'id': 1, 'enabled': True, 'start_datetime': '2022-09-26T13:08:16.281604Z', 'interval_hours': 1, 'error_count': None, 'additional_email_options': [], 'emails_selected': ['[email protected]'], 'workspace': 1, 'schedule': 9, 'updated_at': '2022-05-13', 'created_at': '2022-05-13'} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Ensure consistent usage of auto_now.&auto_now_add
auto_now and auto_now_add are both appropriate here, but confirm consistency across models so that timestamps are always handled in an expected manner.