Skip to content

Commit

Permalink
feat: use participant profile as info and create migrations
Browse files Browse the repository at this point in the history
  • Loading branch information
AvilaAndre committed Feb 11, 2025
1 parent 9faf973 commit c4f26f4
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 74 deletions.
19 changes: 0 additions & 19 deletions website/app/models/participant_info.ts

This file was deleted.

14 changes: 3 additions & 11 deletions website/app/models/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { BaseModel, belongsTo, column, hasMany } from '@adonisjs/lucid/orm'
import Account from './account.js'
import type { BelongsTo, HasMany } from '@adonisjs/lucid/types/relations'
import PromoterInfo from './promoter_info.js'
import ParticipantInfo from './participant_info.js'
import { compose } from '@adonisjs/core/helpers'
import { HasReferralLink } from './mixins/has_referral_link.js'
import ParticipantProfile from './participant_profile.js'
Expand Down Expand Up @@ -45,14 +44,7 @@ export default class User extends compose(BaseModel, HasReferralLink) {
@belongsTo(() => PromoterInfo)
declare promoterInfo: BelongsTo<typeof PromoterInfo>

// ParticipantInfo
@column()
declare participantInfoId: number | null

@belongsTo(() => ParticipantInfo)
declare participantInfo: BelongsTo<typeof ParticipantInfo>

// Profiles
// ParticipantProfile
@column()
declare participantProfileId: number | null

Expand All @@ -65,9 +57,9 @@ export default class User extends compose(BaseModel, HasReferralLink) {
}

isParticipant() {
return this.participantInfoId !== null
return this.participantProfileId !== null
}

isEmailVerified() {
return this.emailVerifiedAt !== null
}
Expand Down

This file was deleted.

25 changes: 0 additions & 25 deletions website/database/migrations/1739128445636_alter_users_table.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ export default class extends BaseSchema {
async down() {
this.schema.dropTable(this.tableName)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,13 @@ export default class extends BaseSchema {

async up() {
this.schema.alterTable(this.tableName, (table) => {
table.integer('promoter_info_id')
.unique()
.references('id')
.inTable('promoter_infos')

table.integer('points').defaultTo(0)

table.integer('referred_by_promoter_id')
.unsigned()
.nullable()
Expand All @@ -17,7 +23,10 @@ export default class extends BaseSchema {

async down() {
this.schema.alterTable(this.tableName, (table) => {
table.dropColumn('promoter_info_id')

table.dropColumn('points')

table.dropColumn('referred_by_promoter_id')
})
}
Expand Down

0 comments on commit c4f26f4

Please sign in to comment.