forked from rDrama/rDrama
Add foreignkey
parent
562202b38d
commit
d1f0f7a164
|
@ -13,6 +13,7 @@ class Lottery(Base):
|
|||
ends_at = Column(Integer)
|
||||
prize = Column(Integer, default=0)
|
||||
tickets_sold = Column(Integer, default=0)
|
||||
winner_id = Column(Integer, ForeignKey("users.id"))
|
||||
|
||||
@property
|
||||
@lazy
|
||||
|
|
|
@ -122,15 +122,6 @@
|
|||
|
||||
12
|
||||
</button>
|
||||
<script>
|
||||
const userCoinCount = {{v.coins}};
|
||||
const ticketCost = 12;
|
||||
|
||||
if (userCoinCount < ticketCost) {
|
||||
const purchaseTicketButton = document.getElementById('purchaseTicket');
|
||||
purchaseTicketButton.disabled = true;
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
30
lottery.sql
30
lottery.sql
|
@ -1,30 +0,0 @@
|
|||
CREATE TABLE public.lotteries (
|
||||
id SERIAL PRIMARY KEY,
|
||||
is_active boolean DEFAULT false NOT NULL,
|
||||
ends_at integer NOT NULL,
|
||||
prize integer DEFAULT 0 NOT NULL,
|
||||
tickets_sold integer DEFAULT 0 NOT NULL
|
||||
);
|
||||
|
||||
--
|
||||
-- Name: lotteries_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE public.lotteries_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
--
|
||||
-- Name: lotteries_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE public.lotteries_id_seq OWNED BY public.lotteries.id;
|
||||
|
||||
ALTER TABLE public.users
|
||||
ADD currently_held_lottery_tickets integer DEFAULT 0 NOT NULL,
|
||||
ADD total_held_lottery_tickets integer DEFAULT 0 NOT NULL,
|
||||
ADD total_lottery_winnings integer DEFAULT 0 NOT NULL;
|
Loading…
Reference in New Issue