Skip to content

Commit

Permalink
Merge pull request #58 from marmelab/adapt-database-schema-with-demo
Browse files Browse the repository at this point in the history
Adapt database schema with the demo
  • Loading branch information
djhi authored Jun 10, 2024
2 parents d51da2a + b72b1f6 commit a3c8fe4
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/demo/db-seed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ async function main() {
});
const { data: persistedContacts, error: errorContacts } = await supabase
.from('contacts')
.insert(contacts)
.insert(contacts.map(({ id, ...contact }) => contact))
.select();

if (errorContacts) {
Expand Down
15 changes: 12 additions & 3 deletions packages/demo/src/contacts/ContactInputs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,31 @@ import {
ReferenceInput,
AutocompleteInput,
BooleanInput,
required,
} from 'react-admin';
import { Divider, Box } from '@mui/material';

export const ContactInputs = () => {
return (
<Box flex="1" mt={-1}>
<Box display="flex" width={430}>
<TextInput source="first_name" fullWidth />
<TextInput
source="first_name"
validate={required()}
fullWidth
/>
<Spacer />
<TextInput source="last_name" fullWidth />
<TextInput source="last_name" validate={required()} fullWidth />
</Box>
<Box display="flex" width={430}>
<TextInput source="title" fullWidth />
<Spacer />
<ReferenceInput source="company_id" reference="companies">
<AutocompleteInput optionText="name" fullWidth />
<AutocompleteInput
optionText="name"
fullWidth
validate={required()}
/>
</ReferenceInput>
</Box>
<Divider />
Expand Down
31 changes: 31 additions & 0 deletions supabase/migrations/20240606161030_allow_nullable.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
alter table "public"."companies" alter column "address" drop not null;
alter table "public"."companies" alter column "city" drop not null;
alter table "public"."companies" alter column "created_at" drop not null;
alter table "public"."companies" alter column "linkedIn" drop not null;
alter table "public"."companies" alter column "logo" drop not null;
alter table "public"."companies" alter column "phone_number" drop not null;
alter table "public"."companies" alter column "sales_id" drop not null;
alter table "public"."companies" alter column "sector" drop not null;
alter table "public"."companies" alter column "size" drop not null;
alter table "public"."companies" alter column "stateAbbr" drop not null;
alter table "public"."companies" alter column "website" drop not null;
alter table "public"."companies" alter column "zipcode" drop not null;
alter table "public"."contacts" alter column "acquisition" drop not null;
alter table "public"."contacts" alter column "background" drop not null;
alter table "public"."contacts" alter column "email" drop not null;
alter table "public"."contacts" alter column "first_seen" drop not null;
alter table "public"."contacts" alter column "gender" drop not null;
alter table "public"."contacts" alter column "last_seen" drop not null;
alter table "public"."contacts" alter column "phone_number1" drop not null;
alter table "public"."contacts" alter column "phone_number2" drop not null;
alter table "public"."contacts" alter column "sales_id" drop not null;
alter table "public"."contacts" alter column "status" drop not null;
alter table "public"."contacts" alter column "title" drop not null;
alter table "public"."deals" alter column "amount" drop not null;
alter table "public"."deals" alter column "contact_ids" drop not null;
alter table "public"."deals" alter column "created_at" drop not null;
alter table "public"."deals" alter column "description" drop not null;
alter table "public"."deals" alter column "sales_id" drop not null;
alter table "public"."deals" alter column "start_at" drop not null;
alter table "public"."deals" alter column "type" drop not null;
alter table "public"."deals" alter column "updated_at" drop not null;

0 comments on commit a3c8fe4

Please sign in to comment.