summary refs log tree commit diff
path: root/migrate.py
diff options
context:
space:
mode:
Diffstat (limited to 'migrate.py')
-rwxr-xr-xmigrate.py50
1 files changed, 50 insertions, 0 deletions
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()