Skip to content
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

Refactor/camel case schema #113

Merged
merged 11 commits into from
Dec 8, 2021
38 changes: 19 additions & 19 deletions src/app/components/Title/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ interface Publisher {
publisher: SelectType;
classification: string;
edition: string;
published_at: Date;
publishedAt: Date;
}

const Title: React.FC = () => {
Expand All @@ -39,7 +39,7 @@ const Title: React.FC = () => {

const [classification, setClassification] = useState('');
const [edition, setEdition] = useState('');
const [published_at, setPublished_At] = useState('');
const [publishedAt, setPublishedAt] = useState('');
const [publishers, setPublishers] = useState<Publisher[]>([]);
const refPublisher = useRef<SelectHandles>(null);

Expand All @@ -61,8 +61,8 @@ const Title: React.FC = () => {
if (!edition) {
errors.push(i18n.t('title.edition'));
}
if (!published_at) {
errors.push(i18n.t('title.published_at'));
if (!publishedAt) {
errors.push(i18n.t('title.publishedAt'));
}
if (errors.length > 0) {
addToast({
Expand All @@ -89,16 +89,16 @@ const Title: React.FC = () => {
const pub = {
classification,
edition,
published_at: parseISO(published_at),
publishedAt: parseISO(publishedAt),
publisher,
};
setPublishers((oldState) => [...oldState, pub]);

refPublisher.current.clear();
setClassification('');
setEdition('');
setPublished_At('');
}, [addToast, classification, edition, published_at, publishers]);
setPublishedAt('');
}, [addToast, classification, edition, publishedAt, publishers]);

const handleRemovePublisher = useCallback(
(publisher: Publisher) => {
Expand Down Expand Up @@ -186,8 +186,8 @@ const Title: React.FC = () => {
window.api.sendSync('create', {
entity: 'TitleCategory',
value: {
title_id: result.id,
category_id: category.id,
titleId: result.id,
categoryId: category.id,
},
});
});
Expand All @@ -196,8 +196,8 @@ const Title: React.FC = () => {
window.api.sendSync('create', {
entity: 'TitleAuthor',
value: {
title_id: result.id,
author_id: author.id,
titleId: result.id,
authorId: author.id,
},
});
});
Expand All @@ -206,11 +206,11 @@ const Title: React.FC = () => {
window.api.sendSync('create', {
entity: 'TitlePublisher',
value: {
title_id: result.id,
publisher_id: edition.publisher.id,
titleId: result.id,
publisherId: edition.publisher.id,
edition: edition.edition,
classification: edition.classification,
published_at: edition.published_at,
publishedAt: edition.publishedAt,
},
});
});
Expand Down Expand Up @@ -294,11 +294,11 @@ const Title: React.FC = () => {
<Input
type="date"
name="edition_date"
label={i18n.t('title.published_at')}
label={i18n.t('title.publishedAt')}
placeholder={i18n.t('title.typePublicationDate')}
alt={i18n.t('title.typePublicationDate')}
value={published_at}
onChange={(e) => setPublished_At(e.target.value)}
value={publishedAt}
onChange={(e) => setPublishedAt(e.target.value)}
/>
&nbsp;
<PublisherSelect
Expand All @@ -317,8 +317,8 @@ const Title: React.FC = () => {
<span>{publisher.classification}</span>
<span>{publisher.edition}</span>
<span>
{/* {format(parseISO(publisher.published_at), "dd/MM/yyyy HH:mm'h'")} */}
{format(publisher.published_at, 'dd/MM/yyyy')}
{/* {format(parseISO(publisher.publishedAt), "dd/MM/yyyy HH:mm'h'")} */}
{format(publisher.publishedAt, 'dd/MM/yyyy')}
</span>
<span>{publisher.publisher.name}</span>
<FiTrash2
Expand Down
4 changes: 2 additions & 2 deletions src/database/migration/1637762838040-create_settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ export class createSettings1637762838040 implements MigrationInterface {
isPrimary: true
},
{
name: "days_return_date",
name: "daysReturnDate",
type: "int",
},
{
name: "backup_path",
name: "backupPath",
type: "varchar",
}
]
Expand Down
6 changes: 3 additions & 3 deletions src/database/migration/1637774086085-create_user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ export class createUser1637774086085 implements MigrationInterface {
type: "varchar",
},
{
name: "user_type_id",
name: "userTypeId",
type: "int",
},
]
}), true)

await queryRunner.createForeignKey("user", new TableForeignKey({
columnNames: ["user_type_id"],
columnNames: ["userTypeId"],
referencedColumnNames: ["id"],
referencedTableName: "user_type",
onDelete: "CASCADE"
Expand All @@ -56,7 +56,7 @@ export class createUser1637774086085 implements MigrationInterface {
public async down(queryRunner: QueryRunner): Promise<void> {
const table = await queryRunner.getTable("user");

const userTypeId = table.foreignKeys.find(fk => fk.columnNames.indexOf("user_type_id") !== -1);
const userTypeId = table.foreignKeys.find(fk => fk.columnNames.indexOf("userTypeId") !== -1);
await queryRunner.dropForeignKey("user", userTypeId);

await queryRunner.dropTable("user");
Expand Down
12 changes: 6 additions & 6 deletions src/database/migration/1637775857589-create_user_profile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@ export class createUserProfile1637775857589 implements MigrationInterface {
isPrimary: true
},
{
name: "user_id",
name: "userId",
type: "int",
},
{
name: "profile_id",
name: "profileId",
type: "int",
},
]
}), true)

await queryRunner.createForeignKey("user_profile", new TableForeignKey({
columnNames: ["user_id"],
columnNames: ["userId"],
referencedColumnNames: ["id"],
referencedTableName: "user",
onDelete: "CASCADE"
}));

await queryRunner.createForeignKey("user_profile", new TableForeignKey({
columnNames: ["profile_id"],
columnNames: ["profileId"],
referencedColumnNames: ["id"],
referencedTableName: "profile",
onDelete: "CASCADE"
Expand All @@ -40,10 +40,10 @@ export class createUserProfile1637775857589 implements MigrationInterface {
public async down(queryRunner: QueryRunner): Promise<void> {
const table = await queryRunner.getTable("user_profile");

const profileId = table.foreignKeys.find(fk => fk.columnNames.indexOf("profile_id") !== -1);
const profileId = table.foreignKeys.find(fk => fk.columnNames.indexOf("profileId") !== -1);
await queryRunner.dropForeignKey("user_profile", profileId);

const userId = table.foreignKeys.find(fk => fk.columnNames.indexOf("user_id") !== -1);
const userId = table.foreignKeys.find(fk => fk.columnNames.indexOf("userId") !== -1);
await queryRunner.dropForeignKey("user_profile", userId);

await queryRunner.dropTable("user_profile");
Expand Down
12 changes: 6 additions & 6 deletions src/database/migration/1637777649127-create_title_category.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@ export class createTitleCategory1637777649127 implements MigrationInterface {
isPrimary: true
},
{
name: "title_id",
name: "titleId",
type: "int",
},
{
name: "category_id",
name: "categoryId",
type: "int",
},
]
}), true)

await queryRunner.createForeignKey("title_category", new TableForeignKey({
columnNames: ["title_id"],
columnNames: ["titleId"],
referencedColumnNames: ["id"],
referencedTableName: "title",
onDelete: "CASCADE"
}));

await queryRunner.createForeignKey("title_category", new TableForeignKey({
columnNames: ["category_id"],
columnNames: ["categoryId"],
referencedColumnNames: ["id"],
referencedTableName: "category",
onDelete: "CASCADE"
Expand All @@ -40,10 +40,10 @@ export class createTitleCategory1637777649127 implements MigrationInterface {
public async down(queryRunner: QueryRunner): Promise<void> {
const table = await queryRunner.getTable("title_category");

const categoryId = table.foreignKeys.find(fk => fk.columnNames.indexOf("category_id") !== -1);
const categoryId = table.foreignKeys.find(fk => fk.columnNames.indexOf("categoryId") !== -1);
await queryRunner.dropForeignKey("title_category", categoryId);

const titleId = table.foreignKeys.find(fk => fk.columnNames.indexOf("title_id") !== -1);
const titleId = table.foreignKeys.find(fk => fk.columnNames.indexOf("titleId") !== -1);
await queryRunner.dropForeignKey("title_category", titleId);

await queryRunner.dropTable("title_category");
Expand Down
12 changes: 6 additions & 6 deletions src/database/migration/1637778042645-create_title_author.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@ export class createTitleAuthor1637778042645 implements MigrationInterface {
isPrimary: true
},
{
name: "title_id",
name: "titleId",
type: "int",
},
{
name: "author_id",
name: "authorId",
type: "int",
},
]
}), true)

await queryRunner.createForeignKey("title_author", new TableForeignKey({
columnNames: ["title_id"],
columnNames: ["titleId"],
referencedColumnNames: ["id"],
referencedTableName: "title",
onDelete: "CASCADE"
}));

await queryRunner.createForeignKey("title_author", new TableForeignKey({
columnNames: ["author_id"],
columnNames: ["authorId"],
referencedColumnNames: ["id"],
referencedTableName: "category",
onDelete: "CASCADE"
Expand All @@ -40,10 +40,10 @@ export class createTitleAuthor1637778042645 implements MigrationInterface {
public async down(queryRunner: QueryRunner): Promise<void> {
const table = await queryRunner.getTable("title_author");

const categoryId = table.foreignKeys.find(fk => fk.columnNames.indexOf("author_id") !== -1);
const categoryId = table.foreignKeys.find(fk => fk.columnNames.indexOf("authorId") !== -1);
await queryRunner.dropForeignKey("title_author", categoryId);

const titleId = table.foreignKeys.find(fk => fk.columnNames.indexOf("title_id") !== -1);
const titleId = table.foreignKeys.find(fk => fk.columnNames.indexOf("titleId") !== -1);
await queryRunner.dropForeignKey("title_author", titleId);

await queryRunner.dropTable("title_author");
Expand Down
6 changes: 3 additions & 3 deletions src/database/migration/1637780395265-create_region.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ export class createRegion1637780395265 implements MigrationInterface {
type: "varchar",
},
{
name: "country_id",
name: "countryId",
type: "int",
},

]
}), true)

await queryRunner.createForeignKey("region", new TableForeignKey({
columnNames: ["country_id"],
columnNames: ["countryId"],
referencedColumnNames: ["id"],
referencedTableName: "country",
onDelete: "CASCADE"
Expand All @@ -35,7 +35,7 @@ export class createRegion1637780395265 implements MigrationInterface {
public async down(queryRunner: QueryRunner): Promise<void> {
const table = await queryRunner.getTable("region");

const countryID = table.foreignKeys.find(fk => fk.columnNames.indexOf("country_id") !== -1);
const countryID = table.foreignKeys.find(fk => fk.columnNames.indexOf("countryId") !== -1);
await queryRunner.dropForeignKey("region", countryID);

await queryRunner.dropTable("region");
Expand Down
12 changes: 6 additions & 6 deletions src/database/migration/1637781284674-create_contact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,26 @@ export class createContact1637781284674 implements MigrationInterface {
type: "varchar",
},
{
name: "contact_type_id",
name: "contactTypeId",
type: "int",
},
{
name: "user_id",
name: "userId",
type: "int",
},

]
}), true)

await queryRunner.createForeignKey("contact", new TableForeignKey({
columnNames: ["contact_type_id"],
columnNames: ["contactTypeId"],
referencedColumnNames: ["id"],
referencedTableName: "contact_type",
onDelete: "CASCADE"
}));

await queryRunner.createForeignKey("contact", new TableForeignKey({
columnNames: ["user_id"],
columnNames: ["userId"],
referencedColumnNames: ["id"],
referencedTableName: "user",
onDelete: "CASCADE"
Expand All @@ -47,10 +47,10 @@ export class createContact1637781284674 implements MigrationInterface {
public async down(queryRunner: QueryRunner): Promise<void> {
const table = await queryRunner.getTable("contact");

const contactTypeId = table.foreignKeys.find(fk => fk.columnNames.indexOf("contact_type_id") !== -1);
const contactTypeId = table.foreignKeys.find(fk => fk.columnNames.indexOf("contactTypeId") !== -1);
await queryRunner.dropForeignKey("contact", contactTypeId);

const userId = table.foreignKeys.find(fk => fk.columnNames.indexOf("user_id") !== -1);
const userId = table.foreignKeys.find(fk => fk.columnNames.indexOf("userId") !== -1);
await queryRunner.dropForeignKey("contact", userId);

await queryRunner.dropTable("contact");
Expand Down
Loading