Skip to content

Commit

Permalink
build: remove dev fixtures
Browse files Browse the repository at this point in the history
The generated data fixtures in the dev environment aren't helpful as they're not realistic. But worse, there are quite a few problems in this area:

- It fails to run roughly half the time.
- The forked dependency is blocking npm updates.
- The ORM overall is blocking Parcel updates.

Rather than trying to resolve all the issues, this change removes the fixture generation entirely. As a result, the codebase is a fraction simpler.

Refs #399, #406, #421
  • Loading branch information
thewilkybarkid committed Oct 21, 2021
1 parent 9fa1177 commit 64e7259
Show file tree
Hide file tree
Showing 28 changed files with 0 additions and 255 deletions.
12 changes: 0 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,6 @@ Create the database:
npm run db:migrations
```

and to optionally populate it with test data:

```
npm run db:seeds
```

And start the running processes (with necessary environment variables if not
defined in `.env`):

Expand Down Expand Up @@ -116,12 +110,6 @@ database migrations to initialize the database:
docker-compose run prereview npm run db:migrations
```

and then optionally seed the database with a default admin user:

```
docker-compose run prereview npm run db:seeds
```

By default, it runs on [http://localhost:3000](http://localhost:3000), but you
can place it behind a proxy such as [Nginx](https://nginx.com) in order to
provide TLS support and other features.
Expand Down
4 changes: 0 additions & 4 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ else

if [ $result -ne 0 ]; then
init_db
if [ $NODE_ENV == "development" ]; then
echo "Generate seeds"
npm run db:seeds &
fi
else
echo "Updating database schema"
npm run db:migrations
Expand Down
77 changes: 0 additions & 77 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"db": "mikro-orm",
"db:migrations": "node dist/scripts/dbMigrations.js",
"db:apiKey": "ts-node src/backend/scripts/dbApiKey.ts",
"db:seeds": "ts-node src/backend/scripts/dbSeeds.ts",
"db:init": "node dist/scripts/dbInit.js",
"scan:migrations": "barrelsby --delete -l below -d src/backend/db/migrations",
"start:backend": "node dist/backend/index.js",
Expand Down Expand Up @@ -83,7 +82,6 @@
"@mikro-orm/postgresql": "^4.5.4",
"@reach/tooltip": "^0.10.5",
"anonymus": "^2.0.0",
"class-fixtures-factory": "^1.6.1",
"clipboard-copy": "^3.1.0",
"combined-stream": "^1.0.8",
"commander": "^5.1.0",
Expand Down Expand Up @@ -159,7 +157,6 @@
},
"devDependencies": {
"@mikro-orm/cli": "^4.5.4",
"@mikro-resources/fixtures": "throneless-tech/mikro-resources#just-fixtures",
"@parcel/transformer-image": "2.0.0-beta.2",
"@parcel/transformer-typescript-tsc": "2.0.0-beta.2",
"@parcel/validator-typescript": "2.0.0-beta.2",
Expand Down
3 changes: 0 additions & 3 deletions src/backend/models/entities/Badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
Property,
Unique,
} from '@mikro-orm/core';
import { Fixture } from 'class-fixtures-factory';
import { BadgeModel } from '../badges';
import { BaseEntity } from './BaseEntity';
import { Persona } from './Persona';
Expand All @@ -15,12 +14,10 @@ import { Persona } from './Persona';
export class Badge extends BaseEntity {
[EntityRepositoryType]?: BadgeModel;

@Fixture(faker => `${faker.commerce.color()} ${faker.random.word()}`)
@Property()
@Unique()
name!: string;

@Fixture(faker => faker.internet.color())
@Property()
color?: string;

Expand Down
2 changes: 0 additions & 2 deletions src/backend/models/entities/BaseEntity.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import { v4 as uuidv4 } from 'uuid';
import { PrimaryKey, Property, Unique } from '@mikro-orm/core';
import { Fixture } from 'class-fixtures-factory';

export abstract class BaseEntity {
@PrimaryKey({ hidden: true })
id!: number;

@Fixture(() => uuidv4())
@Property({ type: 'string' })
@Unique()
uuid = uuidv4();
Expand Down
2 changes: 0 additions & 2 deletions src/backend/models/entities/Comment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
ManyToOne,
Property,
} from '@mikro-orm/core';
import { Fixture } from 'class-fixtures-factory';
import { CommentModel } from '../comments';
import { BaseEntity } from './BaseEntity';
import { FullReview } from './FullReview';
Expand All @@ -17,7 +16,6 @@ import { Persona } from './Persona';
export class Comment extends BaseEntity {
[EntityRepositoryType]?: CommentModel;

@Fixture(faker => faker.lorem.sentences())
@Property({ columnType: 'text' })
contents!: string;

Expand Down
7 changes: 0 additions & 7 deletions src/backend/models/entities/Community.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
Property,
Unique,
} from '@mikro-orm/core';
import { Fixture } from 'class-fixtures-factory';
import { CommunityModel } from '../communities';
import { BaseEntity } from './BaseEntity';
import { Event } from './Event';
Expand All @@ -21,29 +20,23 @@ import { User } from './User';
export class Community extends BaseEntity {
[EntityRepositoryType]?: CommunityModel;

@Fixture(faker => `${faker.commerce.color()} ${faker.random.word()}`)
@Property()
@Unique()
name!: string;

@Fixture(faker => `${faker.commerce.color()}-${faker.random.word()}`)
@Property()
@Unique()
slug!: string;

@Fixture(faker => faker.lorem.sentences())
@Property({ columnType: 'text', nullable: true })
description?: string;

@Fixture(faker => faker.image.abstract())
@Property({ nullable: true })
banner?: Buffer;

@Fixture(faker => faker.image.abstract())
@Property({ nullable: true })
logo?: Buffer;

@Fixture(faker => faker.internet.userName())
@Property({ nullable: true })
twitter?: string;

Expand Down
7 changes: 0 additions & 7 deletions src/backend/models/entities/Contact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
ManyToOne,
Property,
} from '@mikro-orm/core';
import { Fixture } from 'class-fixtures-factory';
import { ContactModel } from '../contacts';
import { BaseEntity } from './BaseEntity';
import { User } from './User';
Expand All @@ -15,30 +14,24 @@ import { User } from './User';
export class Contact extends BaseEntity {
[EntityRepositoryType]?: ContactModel;

@Fixture(() => 'mailto')
@Property()
schema!: string;

@Fixture(faker => faker.internet.email())
@Property()
value!: string;

@ManyToOne({ entity: () => User })
identity!: User;

@Fixture(() => false)
@Property()
isVerified: boolean;

@Fixture(() => false)
@Property()
isNotified: boolean;

@Fixture(() => false)
@Property()
isPublic: boolean;

@Fixture(faker => faker.random.alphaNumeric(16))
@Property({ nullable: true })
token?: string;

Expand Down
6 changes: 0 additions & 6 deletions src/backend/models/entities/Event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
ManyToOne,
Property,
} from '@mikro-orm/core';
import { Fixture } from 'class-fixtures-factory';
import { EventModel } from '../events';
import { BaseEntity } from './BaseEntity';
import { Community } from './Community';
Expand All @@ -13,26 +12,21 @@ import { Community } from './Community';
export class Event extends BaseEntity {
[EntityRepositoryType]?: EventModel;

@Fixture(faker => `${faker.commerce.color()} ${faker.random.word()}`)
@Property()
title!: string;

@Fixture(() => new Date())
@Property()
start!: Date;

@Fixture(() => new Date())
@Property({ nullable: true })
end?: Date;

@Property()
isPrivate: boolean = false;

@Fixture(faker => faker.lorem.sentences())
@Property({ columnType: 'text', nullable: true })
description?: string;

@Fixture(faker => faker.internet.url())
@Property({ columnType: 'text', nullable: true })
url?: string;

Expand Down
2 changes: 0 additions & 2 deletions src/backend/models/entities/Expertise.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
Property,
Unique,
} from '@mikro-orm/core';
import { Fixture } from 'class-fixtures-factory';
import { ExpertiseModel } from '../expertises';
import { BaseEntity } from './BaseEntity';
import { Persona } from './Persona';
Expand All @@ -15,7 +14,6 @@ import { Persona } from './Persona';
export class Expertise extends BaseEntity {
[EntityRepositoryType]?: ExpertiseModel;

@Fixture(faker => `${faker.commerce.color()} ${faker.random.word()}`)
@Property()
@Unique()
name!: string;
Expand Down
Loading

0 comments on commit 64e7259

Please sign in to comment.