diff --git a/front/.env.example b/front/.env.example index b4ab84278..deb105c8c 100644 --- a/front/.env.example +++ b/front/.env.example @@ -1 +1 @@ -REACT_APP_API_URL=http://localhost:3000 \ No newline at end of file +REACT_APP_API_URL=http://localhost:8080 \ No newline at end of file diff --git a/front/src/components/table/ClickableCell.tsx b/front/src/components/table/ClickableCell.tsx index e30bd8a06..ddd382075 100644 --- a/front/src/components/table/ClickableCell.tsx +++ b/front/src/components/table/ClickableCell.tsx @@ -31,6 +31,11 @@ const StyledClickable = styled.div` :hover::before { display: block; } + + a { + color: inherit; + text-decoration: none; + } `; const Container = styled.span` diff --git a/front/src/components/table/Table.tsx b/front/src/components/table/Table.tsx index 2926b159f..da7ea635a 100644 --- a/front/src/components/table/Table.tsx +++ b/front/src/components/table/Table.tsx @@ -10,9 +10,9 @@ import TableHeader from './table-header/TableHeader'; import { IconProp } from '@fortawesome/fontawesome-svg-core'; import styled from '@emotion/styled'; -type OwnProps = { - data: Array; - columns: Array>; +type OwnProps = { + data: Array; + columns: Array>; viewName: string; viewIcon?: IconProp; }; @@ -60,7 +60,7 @@ const StyledTableWithHeader = styled.div` flex: 1; `; -function Table({ data, columns, viewName, viewIcon }: OwnProps) { +function Table({ data, columns, viewName, viewIcon }: OwnProps) { const table = useReactTable({ data, columns, diff --git a/front/src/index.tsx b/front/src/index.tsx index 3c13d9d96..2a3c1c11a 100644 --- a/front/src/index.tsx +++ b/front/src/index.tsx @@ -13,11 +13,13 @@ import { setContext } from '@apollo/client/link/context'; import '@emotion/react'; import { ThemeType } from './layout/styles/themes'; -const httpLink = createHttpLink({ uri: process.env.REACT_APP_API_URL }); +const httpLink = createHttpLink({ + uri: `${process.env.REACT_APP_API_URL}/v1/graphql`, +}); const authLink = setContext((_, { headers }) => { return { - headers: headers, + headers: { ...headers, 'x-hasura-admin-secret': 'secret' }, }; }); diff --git a/front/src/pages/people/People.tsx b/front/src/pages/people/People.tsx index 368da4812..df4226800 100644 --- a/front/src/pages/people/People.tsx +++ b/front/src/pages/people/People.tsx @@ -1,196 +1,52 @@ -import { - faBuildings, - faCalendar, - faEnvelope, - faUser, - faMapPin, - faPhone, - faRectangleHistory, - faList, -} from '@fortawesome/pro-regular-svg-icons'; +import { faUser, faList } from '@fortawesome/pro-regular-svg-icons'; import WithTopBarContainer from '../../layout/containers/WithTopBarContainer'; import Table from '../../components/table/Table'; -import { Company } from '../../interfaces/company.interface'; -import { Pipe } from '../../interfaces/pipe.interface'; -import { createColumnHelper } from '@tanstack/react-table'; import styled from '@emotion/styled'; -import ClickableCell from '../../components/table/ClickableCell'; -import ColumnHead from '../../components/table/ColumnHead'; -import { parsePhoneNumber, CountryCode } from 'libphonenumber-js'; -import Checkbox from '../../components/form/Checkbox'; -import HorizontalyAlignedContainer from '../../layout/containers/HorizontalyAlignedContainer'; -import CompanyChip from '../../components/chips/CompanyChip'; -import PersonChip from '../../components/chips/PersonChip'; - -type Person = { - fullName: string; - picture?: string; - email: string; - company: Company; - phone: string; - creationDate: Date; - pipe: Pipe; - city: string; - countryCode: string; -}; +import { peopleColumns } from './people-table'; +import { gql, useQuery } from '@apollo/client'; +import { GraphqlPerson, Person } from './types'; +import { defaultData } from './default-data'; +import { mapPerson } from './mapper'; const StyledPeopleContainer = styled.div` display: flex; width: 100%; +`; - a { - color: inherit; - text-decoration: none; +export const GET_PEOPLE = gql` + query GetPeople { + person { + id + phone + email + city + firstname + lastname + created_at + company { + company_name + company_domain + } + } } `; -const defaultData: Array = [ - { - fullName: 'Alexandre Prot', - picture: 'http://placekitten.com/256', - email: 'alexandre@qonto.com', - company: { id: 1, name: 'Qonto', domain: 'qonto.com' }, - phone: '06 12 34 56 78', - creationDate: new Date('Feb 23, 2018'), - pipe: { id: 1, name: 'Sales Pipeline', icon: 'faUser' }, - city: 'Paris', - countryCode: 'FR', - }, - { - fullName: 'Alexandre Prot', - email: 'alexandre@qonto.com', - company: { id: 2, name: 'LinkedIn', domain: 'linkedin.com' }, - phone: '06 12 34 56 78', - creationDate: new Date('Feb 23, 2018'), - pipe: { id: 1, name: 'Sales Pipeline', icon: 'faUser' }, - city: 'Paris', - countryCode: 'FR', - }, - { - fullName: 'Alexandre Prot', - picture: 'http://placekitten.com/256', - email: 'alexandre@qonto.com', - company: { id: 1, name: 'Qonto', domain: 'qonto.com' }, - phone: '06 12 34 56 78', - creationDate: new Date('Feb 23, 2018'), - pipe: { id: 1, name: 'Sales Pipeline', icon: 'faUser' }, - city: 'Paris', - countryCode: 'FR', - }, - { - fullName: 'Alexandre Prot', - picture: 'https://placekitten.com/g/256', - email: 'alexandre@qonto.com', - company: { id: 1, name: 'Slack', domain: 'slack.com' }, - phone: '06 12 34 56 78', - creationDate: new Date('Feb 23, 2018'), - pipe: { id: 1, name: 'Sales Pipeline', icon: 'faUser' }, - city: 'Paris', - countryCode: 'FR', - }, - { - fullName: 'Alexandre Prot', - email: 'alexandre@qonto.com', - company: { id: 2, name: 'Facebook', domain: 'facebook.com' }, - phone: '06 12 34 56 78', - creationDate: new Date('Feb 23, 2018'), - pipe: { id: 1, name: 'Sales Pipeline', icon: 'faUser' }, - city: 'Paris', - countryCode: 'FR', - }, -]; - -const columnHelper = createColumnHelper(); - -const columns = [ - columnHelper.accessor('fullName', { - header: () => , - cell: (props) => ( - <> - - - - - - ), - }), - columnHelper.accessor('email', { - header: () => , - cell: (props) => ( - - {props.row.original.email} - - ), - }), - columnHelper.accessor('company', { - header: () => , - cell: (props) => ( - - - - ), - }), - columnHelper.accessor('phone', { - header: () => , - cell: (props) => ( - - {parsePhoneNumber( - props.row.original.phone, - props.row.original.countryCode as CountryCode, - )?.formatInternational() || props.row.original.phone} - - ), - }), - columnHelper.accessor('creationDate', { - header: () => , - cell: (props) => ( - - {new Intl.DateTimeFormat(undefined, { - month: 'short', - day: 'numeric', - year: 'numeric', - }).format(props.row.original.creationDate)} - - ), - }), - columnHelper.accessor('pipe', { - header: () => , - cell: (props) => ( - {props.row.original.pipe.name} - ), - }), - columnHelper.accessor('city', { - header: () => , - cell: (props) => ( - {props.row.original.city} - ), - }), -]; - function People() { + const { data } = useQuery<{ person: GraphqlPerson[] }>(GET_PEOPLE); + + const mydata: Person[] = data ? data.person.map(mapPerson) : defaultData; + return ( - + {mydata && ( +
+ )} ); diff --git a/front/src/pages/people/__stories__/People.stories.tsx b/front/src/pages/people/__stories__/People.stories.tsx index 24d4c6803..02ec4f45e 100644 --- a/front/src/pages/people/__stories__/People.stories.tsx +++ b/front/src/pages/people/__stories__/People.stories.tsx @@ -1,7 +1,9 @@ import { MemoryRouter } from 'react-router-dom'; -import People from '../People'; +import People, { GET_PEOPLE } from '../People'; import { ThemeProvider } from '@emotion/react'; import { lightTheme } from '../../../layout/styles/themes'; +import { MockedProvider } from '@apollo/client/testing'; +import { defaultData } from '../default-data'; const component = { title: 'People', @@ -10,10 +12,25 @@ const component = { export default component; +const mocks = [ + { + request: { + query: GET_PEOPLE, + }, + result: { + data: { + person: defaultData, + }, + }, + }, +]; + export const PeopleDefault = () => ( - - - - - + + + + + + + ); diff --git a/front/src/pages/people/default-data.ts b/front/src/pages/people/default-data.ts new file mode 100644 index 000000000..e071b07f8 --- /dev/null +++ b/front/src/pages/people/default-data.ts @@ -0,0 +1,47 @@ +import { Person } from './types'; + +export const defaultData: Array = [ + { + fullName: 'Alexandre Prot', + picture: 'http://placekitten.com/256', + email: 'alexandre@qonto.com', + company: { id: 1, name: 'Qonto', domain: 'qonto.com' }, + phone: '06 12 34 56 78', + creationDate: new Date('Feb 23, 2018'), + pipe: { id: 1, name: 'Sales Pipeline', icon: 'faUser' }, + city: 'Paris', + countryCode: 'FR', + }, + { + fullName: 'Alexandre Prot', + email: 'alexandre@qonto.com', + company: { id: 2, name: 'LinkedIn', domain: 'linkedin.com' }, + phone: '06 12 34 56 78', + creationDate: new Date('Feb 22, 2018'), + pipe: { id: 1, name: 'Sales Pipeline', icon: 'faUser' }, + city: 'Paris', + countryCode: 'FR', + }, + { + fullName: 'Alexandre Prot', + picture: 'http://placekitten.com/256', + email: 'alexandre@qonto.com', + company: { id: 5, name: 'Sequoia', domain: 'sequoiacap.com' }, + phone: '06 12 34 56 78', + creationDate: new Date('Feb 21, 2018'), + pipe: { id: 1, name: 'Sales Pipeline', icon: 'faUser' }, + city: 'Paris', + countryCode: 'FR', + }, + + { + fullName: 'Alexandre Prot', + email: 'alexandre@qonto.com', + company: { id: 2, name: 'Facebook', domain: 'facebook.com' }, + phone: '06 12 34 56 78', + creationDate: new Date('Feb 25, 2018'), + pipe: { id: 1, name: 'Sales Pipeline', icon: 'faUser' }, + city: 'Paris', + countryCode: 'FR', + }, +]; diff --git a/front/src/pages/people/mapper.ts b/front/src/pages/people/mapper.ts new file mode 100644 index 000000000..5ae21b954 --- /dev/null +++ b/front/src/pages/people/mapper.ts @@ -0,0 +1,14 @@ +import { GraphqlPerson, Person } from './types'; + +export const mapPerson = (person: GraphqlPerson): Person => ({ + fullName: `${person.firstname} ${person.lastname}`, + creationDate: new Date(person.created_at), + pipe: { name: 'coucou', id: 1, icon: 'faUser' }, + ...person, + company: { + id: 1, + name: person.company.company_name, + domain: person.company.company_domain, + }, + countryCode: 'FR', +}); diff --git a/front/src/pages/people/people-table.tsx b/front/src/pages/people/people-table.tsx new file mode 100644 index 000000000..b1063a7eb --- /dev/null +++ b/front/src/pages/people/people-table.tsx @@ -0,0 +1,98 @@ +import { + faBuildings, + faCalendar, + faEnvelope, + faUser, + faMapPin, + faPhone, + faRectangleHistory, +} from '@fortawesome/pro-regular-svg-icons'; +import { createColumnHelper } from '@tanstack/react-table'; +import ClickableCell from '../../components/table/ClickableCell'; +import ColumnHead from '../../components/table/ColumnHead'; +import { parsePhoneNumber, CountryCode } from 'libphonenumber-js'; +import Checkbox from '../../components/form/Checkbox'; +import HorizontalyAlignedContainer from '../../layout/containers/HorizontalyAlignedContainer'; +import CompanyChip from '../../components/chips/CompanyChip'; +import PersonChip from '../../components/chips/PersonChip'; +import { Person } from './types'; + +const columnHelper = createColumnHelper(); +export const peopleColumns = [ + columnHelper.accessor('fullName', { + header: () => , + cell: (props) => ( + <> + + + + + + ), + }), + columnHelper.accessor('email', { + header: () => , + cell: (props) => ( + + {props.row.original.email} + + ), + }), + columnHelper.accessor('company', { + header: () => , + cell: (props) => ( + + + + ), + }), + columnHelper.accessor('phone', { + header: () => , + cell: (props) => ( + + {parsePhoneNumber( + props.row.original.phone, + props.row.original.countryCode as CountryCode, + )?.formatInternational() || props.row.original.phone} + + ), + }), + columnHelper.accessor('creationDate', { + header: () => , + cell: (props) => ( + + {new Intl.DateTimeFormat(undefined, { + month: 'short', + day: 'numeric', + year: 'numeric', + }).format(props.row.original.creationDate)} + + ), + }), + columnHelper.accessor('pipe', { + header: () => , + cell: (props) => ( + {props.row.original.pipe.name} + ), + }), + columnHelper.accessor('city', { + header: () => , + cell: (props) => ( + {props.row.original.city} + ), + }), +]; diff --git a/front/src/pages/people/types.ts b/front/src/pages/people/types.ts new file mode 100644 index 000000000..4afd0aeae --- /dev/null +++ b/front/src/pages/people/types.ts @@ -0,0 +1,30 @@ +import { Company } from '../../interfaces/company.interface'; +import { Pipe } from '../../interfaces/pipe.interface'; + +export type Person = { + fullName: string; + picture?: string; + email: string; + company: Company; + phone: string; + creationDate: Date; + pipe: Pipe; + city: string; + countryCode: string; +}; + +export type GraphqlPerson = { + city: string; + company: { + __typename: string; + company_name: string; + company_domain: string; + }; + created_at: string; + email: string; + firstname: string; + id: number; + lastname: string; + phone: string; + __typename: string; +}; diff --git a/hasura/metadata/databases/default/tables/public_Person.yaml b/hasura/metadata/databases/default/tables/public_Person.yaml new file mode 100644 index 000000000..b26e35d5c --- /dev/null +++ b/hasura/metadata/databases/default/tables/public_Person.yaml @@ -0,0 +1,10 @@ +table: + name: person + schema: public +object_relationships: + - name: company + using: + foreign_key_constraint_on: company_id + - name: workspace + using: + foreign_key_constraint_on: workspace_id diff --git a/hasura/metadata/databases/default/tables/public_company.yaml b/hasura/metadata/databases/default/tables/public_company.yaml new file mode 100644 index 000000000..83f6139c5 --- /dev/null +++ b/hasura/metadata/databases/default/tables/public_company.yaml @@ -0,0 +1,3 @@ +table: + name: company + schema: public diff --git a/hasura/metadata/databases/default/tables/tables.yaml b/hasura/metadata/databases/default/tables/tables.yaml index 64aa5e713..7a5556d64 100644 --- a/hasura/metadata/databases/default/tables/tables.yaml +++ b/hasura/metadata/databases/default/tables/tables.yaml @@ -1 +1,3 @@ +- "!include public_company.yaml" +- "!include public_person.yaml" - "!include public_workspaces.yaml" diff --git a/hasura/migrations/default/1681983598184_create_table_public_person/down.sql b/hasura/migrations/default/1681983598184_create_table_public_person/down.sql new file mode 100644 index 000000000..88eace82c --- /dev/null +++ b/hasura/migrations/default/1681983598184_create_table_public_person/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."person"; diff --git a/hasura/migrations/default/1681983598184_create_table_public_person/up.sql b/hasura/migrations/default/1681983598184_create_table_public_person/up.sql new file mode 100644 index 000000000..eae86aa1e --- /dev/null +++ b/hasura/migrations/default/1681983598184_create_table_public_person/up.sql @@ -0,0 +1 @@ +CREATE TABLE "public"."person" ("id" serial NOT NULL, "firstname" text, "lastname" text NOT NULL, "company_domain" text, "phone" text, "city" text, PRIMARY KEY ("id") , UNIQUE ("id")); diff --git a/hasura/migrations/default/1681984687438_alter_table_public_person_add_column_workspace_id/down.sql b/hasura/migrations/default/1681984687438_alter_table_public_person_add_column_workspace_id/down.sql new file mode 100644 index 000000000..4c7f3f55b --- /dev/null +++ b/hasura/migrations/default/1681984687438_alter_table_public_person_add_column_workspace_id/down.sql @@ -0,0 +1,4 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- alter table "public"."person" add column "workspace_id" integer +-- not null; diff --git a/hasura/migrations/default/1681984687438_alter_table_public_person_add_column_workspace_id/up.sql b/hasura/migrations/default/1681984687438_alter_table_public_person_add_column_workspace_id/up.sql new file mode 100644 index 000000000..a206c9e2b --- /dev/null +++ b/hasura/migrations/default/1681984687438_alter_table_public_person_add_column_workspace_id/up.sql @@ -0,0 +1,2 @@ +alter table "public"."person" add column "workspace_id" integer + not null; diff --git a/hasura/migrations/default/1681984711213_set_fk_public_person_workspace_id/down.sql b/hasura/migrations/default/1681984711213_set_fk_public_person_workspace_id/down.sql new file mode 100644 index 000000000..836d8871c --- /dev/null +++ b/hasura/migrations/default/1681984711213_set_fk_public_person_workspace_id/down.sql @@ -0,0 +1 @@ +alter table "public"."person" drop constraint "person_workspace_id_fkey"; diff --git a/hasura/migrations/default/1681984711213_set_fk_public_person_workspace_id/up.sql b/hasura/migrations/default/1681984711213_set_fk_public_person_workspace_id/up.sql new file mode 100644 index 000000000..38947a7d1 --- /dev/null +++ b/hasura/migrations/default/1681984711213_set_fk_public_person_workspace_id/up.sql @@ -0,0 +1,5 @@ +alter table "public"."person" + add constraint "person_workspace_id_fkey" + foreign key ("workspace_id") + references "public"."workspaces" + ("id") on update restrict on delete restrict; diff --git a/hasura/migrations/default/1681984791629_create_table_public_company/down.sql b/hasura/migrations/default/1681984791629_create_table_public_company/down.sql new file mode 100644 index 000000000..58fa51e3e --- /dev/null +++ b/hasura/migrations/default/1681984791629_create_table_public_company/down.sql @@ -0,0 +1 @@ +DROP TABLE "public"."company"; diff --git a/hasura/migrations/default/1681984791629_create_table_public_company/up.sql b/hasura/migrations/default/1681984791629_create_table_public_company/up.sql new file mode 100644 index 000000000..87b562746 --- /dev/null +++ b/hasura/migrations/default/1681984791629_create_table_public_company/up.sql @@ -0,0 +1 @@ +CREATE TABLE "public"."company" ("id" serial NOT NULL, "company_name" text NOT NULL, "company_domain" text NOT NULL, "workspace_id" integer NOT NULL, PRIMARY KEY ("id") , FOREIGN KEY ("workspace_id") REFERENCES "public"."workspaces"("id") ON UPDATE restrict ON DELETE restrict); diff --git a/hasura/migrations/default/1681984808493_alter_table_public_person_add_column_company_id/down.sql b/hasura/migrations/default/1681984808493_alter_table_public_person_add_column_company_id/down.sql new file mode 100644 index 000000000..79b017b2d --- /dev/null +++ b/hasura/migrations/default/1681984808493_alter_table_public_person_add_column_company_id/down.sql @@ -0,0 +1,4 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- alter table "public"."person" add column "company_id" integer +-- null; diff --git a/hasura/migrations/default/1681984808493_alter_table_public_person_add_column_company_id/up.sql b/hasura/migrations/default/1681984808493_alter_table_public_person_add_column_company_id/up.sql new file mode 100644 index 000000000..7f32b5eec --- /dev/null +++ b/hasura/migrations/default/1681984808493_alter_table_public_person_add_column_company_id/up.sql @@ -0,0 +1,2 @@ +alter table "public"."person" add column "company_id" integer + null; diff --git a/hasura/migrations/default/1681984826832_set_fk_public_person_company_id/down.sql b/hasura/migrations/default/1681984826832_set_fk_public_person_company_id/down.sql new file mode 100644 index 000000000..3367634a8 --- /dev/null +++ b/hasura/migrations/default/1681984826832_set_fk_public_person_company_id/down.sql @@ -0,0 +1 @@ +alter table "public"."person" drop constraint "person_company_id_fkey"; diff --git a/hasura/migrations/default/1681984826832_set_fk_public_person_company_id/up.sql b/hasura/migrations/default/1681984826832_set_fk_public_person_company_id/up.sql new file mode 100644 index 000000000..40705de79 --- /dev/null +++ b/hasura/migrations/default/1681984826832_set_fk_public_person_company_id/up.sql @@ -0,0 +1,5 @@ +alter table "public"."person" + add constraint "person_company_id_fkey" + foreign key ("company_id") + references "public"."company" + ("id") on update restrict on delete restrict; diff --git a/hasura/migrations/default/1681984914048_alter_table_public_person_drop_column_company_domain/down.sql b/hasura/migrations/default/1681984914048_alter_table_public_person_drop_column_company_domain/down.sql new file mode 100644 index 000000000..449d39b75 --- /dev/null +++ b/hasura/migrations/default/1681984914048_alter_table_public_person_drop_column_company_domain/down.sql @@ -0,0 +1,2 @@ +alter table "public"."person" alter column "company_domain" drop not null; +alter table "public"."person" add column "company_domain" text; diff --git a/hasura/migrations/default/1681984914048_alter_table_public_person_drop_column_company_domain/up.sql b/hasura/migrations/default/1681984914048_alter_table_public_person_drop_column_company_domain/up.sql new file mode 100644 index 000000000..87528dcbd --- /dev/null +++ b/hasura/migrations/default/1681984914048_alter_table_public_person_drop_column_company_domain/up.sql @@ -0,0 +1 @@ +alter table "public"."person" drop column "company_domain" cascade; diff --git a/hasura/migrations/default/1681984943482_alter_table_public_person_add_column_email/down.sql b/hasura/migrations/default/1681984943482_alter_table_public_person_add_column_email/down.sql new file mode 100644 index 000000000..b08a33c83 --- /dev/null +++ b/hasura/migrations/default/1681984943482_alter_table_public_person_add_column_email/down.sql @@ -0,0 +1,4 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- alter table "public"."person" add column "email" text +-- null; diff --git a/hasura/migrations/default/1681984943482_alter_table_public_person_add_column_email/up.sql b/hasura/migrations/default/1681984943482_alter_table_public_person_add_column_email/up.sql new file mode 100644 index 000000000..92534320a --- /dev/null +++ b/hasura/migrations/default/1681984943482_alter_table_public_person_add_column_email/up.sql @@ -0,0 +1,2 @@ +alter table "public"."person" add column "email" text + null; diff --git a/hasura/migrations/default/1681985666317_alter_table_public_person_add_column_created_at/down.sql b/hasura/migrations/default/1681985666317_alter_table_public_person_add_column_created_at/down.sql new file mode 100644 index 000000000..df344dd4a --- /dev/null +++ b/hasura/migrations/default/1681985666317_alter_table_public_person_add_column_created_at/down.sql @@ -0,0 +1,4 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- alter table "public"."person" add column "created_at" timestamptz +-- null default now(); diff --git a/hasura/migrations/default/1681985666317_alter_table_public_person_add_column_created_at/up.sql b/hasura/migrations/default/1681985666317_alter_table_public_person_add_column_created_at/up.sql new file mode 100644 index 000000000..309b4749f --- /dev/null +++ b/hasura/migrations/default/1681985666317_alter_table_public_person_add_column_created_at/up.sql @@ -0,0 +1,2 @@ +alter table "public"."person" add column "created_at" timestamptz + null default now(); diff --git a/hasura/migrations/default/1681985672955_alter_table_public_person_add_column_updated_at/down.sql b/hasura/migrations/default/1681985672955_alter_table_public_person_add_column_updated_at/down.sql new file mode 100644 index 000000000..46e5a4704 --- /dev/null +++ b/hasura/migrations/default/1681985672955_alter_table_public_person_add_column_updated_at/down.sql @@ -0,0 +1,21 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- alter table "public"."person" add column "updated_at" timestamptz +-- null default now(); +-- +-- CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"() +-- RETURNS TRIGGER AS $$ +-- DECLARE +-- _new record; +-- BEGIN +-- _new := NEW; +-- _new."updated_at" = NOW(); +-- RETURN _new; +-- END; +-- $$ LANGUAGE plpgsql; +-- CREATE TRIGGER "set_public_person_updated_at" +-- BEFORE UPDATE ON "public"."person" +-- FOR EACH ROW +-- EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"(); +-- COMMENT ON TRIGGER "set_public_person_updated_at" ON "public"."person" +-- IS 'trigger to set value of column "updated_at" to current timestamp on row update'; diff --git a/hasura/migrations/default/1681985672955_alter_table_public_person_add_column_updated_at/up.sql b/hasura/migrations/default/1681985672955_alter_table_public_person_add_column_updated_at/up.sql new file mode 100644 index 000000000..d82ca10fc --- /dev/null +++ b/hasura/migrations/default/1681985672955_alter_table_public_person_add_column_updated_at/up.sql @@ -0,0 +1,19 @@ +alter table "public"."person" add column "updated_at" timestamptz + null default now(); + +CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"() +RETURNS TRIGGER AS $$ +DECLARE + _new record; +BEGIN + _new := NEW; + _new."updated_at" = NOW(); + RETURN _new; +END; +$$ LANGUAGE plpgsql; +CREATE TRIGGER "set_public_person_updated_at" +BEFORE UPDATE ON "public"."person" +FOR EACH ROW +EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"(); +COMMENT ON TRIGGER "set_public_person_updated_at" ON "public"."person" +IS 'trigger to set value of column "updated_at" to current timestamp on row update'; diff --git a/hasura/migrations/default/1681985681541_alter_table_public_company_add_column_created_at/down.sql b/hasura/migrations/default/1681985681541_alter_table_public_company_add_column_created_at/down.sql new file mode 100644 index 000000000..67c1fdd6b --- /dev/null +++ b/hasura/migrations/default/1681985681541_alter_table_public_company_add_column_created_at/down.sql @@ -0,0 +1,4 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- alter table "public"."company" add column "created_at" timestamptz +-- null default now(); diff --git a/hasura/migrations/default/1681985681541_alter_table_public_company_add_column_created_at/up.sql b/hasura/migrations/default/1681985681541_alter_table_public_company_add_column_created_at/up.sql new file mode 100644 index 000000000..141d16435 --- /dev/null +++ b/hasura/migrations/default/1681985681541_alter_table_public_company_add_column_created_at/up.sql @@ -0,0 +1,2 @@ +alter table "public"."company" add column "created_at" timestamptz + null default now(); diff --git a/hasura/migrations/default/1681985694121_alter_table_public_company_add_column_updated_at/down.sql b/hasura/migrations/default/1681985694121_alter_table_public_company_add_column_updated_at/down.sql new file mode 100644 index 000000000..b68e0c5b4 --- /dev/null +++ b/hasura/migrations/default/1681985694121_alter_table_public_company_add_column_updated_at/down.sql @@ -0,0 +1,21 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- alter table "public"."company" add column "updated_at" timestamptz +-- not null default now(); +-- +-- CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"() +-- RETURNS TRIGGER AS $$ +-- DECLARE +-- _new record; +-- BEGIN +-- _new := NEW; +-- _new."updated_at" = NOW(); +-- RETURN _new; +-- END; +-- $$ LANGUAGE plpgsql; +-- CREATE TRIGGER "set_public_company_updated_at" +-- BEFORE UPDATE ON "public"."company" +-- FOR EACH ROW +-- EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"(); +-- COMMENT ON TRIGGER "set_public_company_updated_at" ON "public"."company" +-- IS 'trigger to set value of column "updated_at" to current timestamp on row update'; diff --git a/hasura/migrations/default/1681985694121_alter_table_public_company_add_column_updated_at/up.sql b/hasura/migrations/default/1681985694121_alter_table_public_company_add_column_updated_at/up.sql new file mode 100644 index 000000000..7674287ac --- /dev/null +++ b/hasura/migrations/default/1681985694121_alter_table_public_company_add_column_updated_at/up.sql @@ -0,0 +1,19 @@ +alter table "public"."company" add column "updated_at" timestamptz + not null default now(); + +CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"() +RETURNS TRIGGER AS $$ +DECLARE + _new record; +BEGIN + _new := NEW; + _new."updated_at" = NOW(); + RETURN _new; +END; +$$ LANGUAGE plpgsql; +CREATE TRIGGER "set_public_company_updated_at" +BEFORE UPDATE ON "public"."company" +FOR EACH ROW +EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"(); +COMMENT ON TRIGGER "set_public_company_updated_at" ON "public"."company" +IS 'trigger to set value of column "updated_at" to current timestamp on row update'; diff --git a/hasura/migrations/default/1681985702276_alter_table_public_company_alter_column_created_at/down.sql b/hasura/migrations/default/1681985702276_alter_table_public_company_alter_column_created_at/down.sql new file mode 100644 index 000000000..06bb5cde5 --- /dev/null +++ b/hasura/migrations/default/1681985702276_alter_table_public_company_alter_column_created_at/down.sql @@ -0,0 +1 @@ +alter table "public"."company" alter column "created_at" drop not null; diff --git a/hasura/migrations/default/1681985702276_alter_table_public_company_alter_column_created_at/up.sql b/hasura/migrations/default/1681985702276_alter_table_public_company_alter_column_created_at/up.sql new file mode 100644 index 000000000..30b7a1cf8 --- /dev/null +++ b/hasura/migrations/default/1681985702276_alter_table_public_company_alter_column_created_at/up.sql @@ -0,0 +1 @@ +alter table "public"."company" alter column "created_at" set not null; diff --git a/hasura/migrations/default/1681985713183_alter_table_public_person_alter_column_created_at/down.sql b/hasura/migrations/default/1681985713183_alter_table_public_person_alter_column_created_at/down.sql new file mode 100644 index 000000000..448f4fc8c --- /dev/null +++ b/hasura/migrations/default/1681985713183_alter_table_public_person_alter_column_created_at/down.sql @@ -0,0 +1 @@ +alter table "public"."person" alter column "created_at" drop not null; diff --git a/hasura/migrations/default/1681985713183_alter_table_public_person_alter_column_created_at/up.sql b/hasura/migrations/default/1681985713183_alter_table_public_person_alter_column_created_at/up.sql new file mode 100644 index 000000000..502d0d062 --- /dev/null +++ b/hasura/migrations/default/1681985713183_alter_table_public_person_alter_column_created_at/up.sql @@ -0,0 +1 @@ +alter table "public"."person" alter column "created_at" set not null; diff --git a/hasura/migrations/default/1681985718674_alter_table_public_person_alter_column_updated_at/down.sql b/hasura/migrations/default/1681985718674_alter_table_public_person_alter_column_updated_at/down.sql new file mode 100644 index 000000000..b5b239544 --- /dev/null +++ b/hasura/migrations/default/1681985718674_alter_table_public_person_alter_column_updated_at/down.sql @@ -0,0 +1 @@ +alter table "public"."person" alter column "updated_at" drop not null; diff --git a/hasura/migrations/default/1681985718674_alter_table_public_person_alter_column_updated_at/up.sql b/hasura/migrations/default/1681985718674_alter_table_public_person_alter_column_updated_at/up.sql new file mode 100644 index 000000000..e00a57cb2 --- /dev/null +++ b/hasura/migrations/default/1681985718674_alter_table_public_person_alter_column_updated_at/up.sql @@ -0,0 +1 @@ +alter table "public"."person" alter column "updated_at" set not null; diff --git a/hasura/migrations/default/1681985725409_alter_table_public_workspaces_add_column_created_at/down.sql b/hasura/migrations/default/1681985725409_alter_table_public_workspaces_add_column_created_at/down.sql new file mode 100644 index 000000000..02b40206a --- /dev/null +++ b/hasura/migrations/default/1681985725409_alter_table_public_workspaces_add_column_created_at/down.sql @@ -0,0 +1,4 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- alter table "public"."workspaces" add column "created_at" timestamptz +-- not null default now(); diff --git a/hasura/migrations/default/1681985725409_alter_table_public_workspaces_add_column_created_at/up.sql b/hasura/migrations/default/1681985725409_alter_table_public_workspaces_add_column_created_at/up.sql new file mode 100644 index 000000000..1cc09ae52 --- /dev/null +++ b/hasura/migrations/default/1681985725409_alter_table_public_workspaces_add_column_created_at/up.sql @@ -0,0 +1,2 @@ +alter table "public"."workspaces" add column "created_at" timestamptz + not null default now(); diff --git a/hasura/migrations/default/1681985729821_alter_table_public_workspaces_add_column_updated_at/down.sql b/hasura/migrations/default/1681985729821_alter_table_public_workspaces_add_column_updated_at/down.sql new file mode 100644 index 000000000..bc4587372 --- /dev/null +++ b/hasura/migrations/default/1681985729821_alter_table_public_workspaces_add_column_updated_at/down.sql @@ -0,0 +1,21 @@ +-- Could not auto-generate a down migration. +-- Please write an appropriate down migration for the SQL below: +-- alter table "public"."workspaces" add column "updated_at" timestamptz +-- not null default now(); +-- +-- CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"() +-- RETURNS TRIGGER AS $$ +-- DECLARE +-- _new record; +-- BEGIN +-- _new := NEW; +-- _new."updated_at" = NOW(); +-- RETURN _new; +-- END; +-- $$ LANGUAGE plpgsql; +-- CREATE TRIGGER "set_public_workspaces_updated_at" +-- BEFORE UPDATE ON "public"."workspaces" +-- FOR EACH ROW +-- EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"(); +-- COMMENT ON TRIGGER "set_public_workspaces_updated_at" ON "public"."workspaces" +-- IS 'trigger to set value of column "updated_at" to current timestamp on row update'; diff --git a/hasura/migrations/default/1681985729821_alter_table_public_workspaces_add_column_updated_at/up.sql b/hasura/migrations/default/1681985729821_alter_table_public_workspaces_add_column_updated_at/up.sql new file mode 100644 index 000000000..6c3ff37b2 --- /dev/null +++ b/hasura/migrations/default/1681985729821_alter_table_public_workspaces_add_column_updated_at/up.sql @@ -0,0 +1,19 @@ +alter table "public"."workspaces" add column "updated_at" timestamptz + not null default now(); + +CREATE OR REPLACE FUNCTION "public"."set_current_timestamp_updated_at"() +RETURNS TRIGGER AS $$ +DECLARE + _new record; +BEGIN + _new := NEW; + _new."updated_at" = NOW(); + RETURN _new; +END; +$$ LANGUAGE plpgsql; +CREATE TRIGGER "set_public_workspaces_updated_at" +BEFORE UPDATE ON "public"."workspaces" +FOR EACH ROW +EXECUTE PROCEDURE "public"."set_current_timestamp_updated_at"(); +COMMENT ON TRIGGER "set_public_workspaces_updated_at" ON "public"."workspaces" +IS 'trigger to set value of column "updated_at" to current timestamp on row update';