From 86b3c15595708df0593109ca4cefbc7e05acb371 Mon Sep 17 00:00:00 2001 From: Matt Arnold Date: Wed, 16 Apr 2025 04:34:39 -0400 Subject: Add installer script to init the database from zero,. Make profile picture nullable field --- migrate.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100755 migrate.py (limited to 'migrate.py') diff --git a/migrate.py b/migrate.py new file mode 100755 index 0000000..c386a0e --- /dev/null +++ b/migrate.py @@ -0,0 +1,50 @@ +#!/usr/bin/env python +from getpass import getpass +import click +from models import User as NewUser +from models import Faccet, Post +from models import db as database +from models import generate_password_hash + + +first_post = """ +# Welcome to vibes + +Vibes is journaling based forum software. Built for intentional communities and people. +Have fun and be safe +""" +post_subject = "Welcome" +bio_default = "They've been chilling in the basement for a minute" + + +@click.group() +def cli(): + pass + + +@cli.command +def install(): + database.create_tables([NewUser, Post, Faccet]) + + username = click.prompt("Enter a user account name:", default="user", type=str) + profile_name = click.prompt("Enter a profile name:", default="enzo", type=str) + usr = None + passwd = getpass(f"Enter password for {username}: ") + confirm = getpass("Confirm: ") + if passwd != confirm: + click.echo("password mismatch") + return 1 + hashed = generate_password_hash(passwd) + with database: + usr = NewUser.create( + username=username, default_faccet=profile_name, password_hash=hashed + ) + profile = Faccet.create(user_belongs=usr, name=profile_name, bio=bio_default) + Post.create(authour=profile, parent=0, title=post_subject, content=first_post) + + styled = click.style("It worked boot up the app", bold=True, fg="green") + click.echo(styled) + + +if __name__ == "__main__": + cli() -- cgit 1.4.1-2-gfad0