1
1
Fork 0

Better (init) manage script,

and server_default only for timestamps
dev
Jan Kužílek 5 years ago
parent 69be48e569
commit 2d17519f79

@ -1,30 +0,0 @@
#!/bin/bash
export FLASK_APP=yadc
root="."
createdirs() {
mkdir -p instance
mkdir -p instance/post/img
mkdir -p instance/post/jpeg
mkdir -p instance/post/sample
mkdir -p instance/post/thumb
}
prepare_instance() {
python3 -m pipenv install
createdirs
cp yadc/config.def.py instance/config.py
}
prepare_db() {
python3 -m pipenv run flask upgrade
}
case $1 in
"instance"|"")
prepare_instance
;;
"db")
prepare_db
;;
esac

@ -0,0 +1,54 @@
#!/bin/bash
export FLASK_APP=yadc
root="."
pipenv="python3 -m pipenv"
run="$pipenv run"
prepare_venv() { $pipenv install }
prepare_instance() {
mkdir -p instance
mkdir -p instance/post/img
mkdir -p instance/post/jpeg
mkdir -p instance/post/sample
mkdir -p instance/post/thumb
cp yadc/config.def.py instance/config.py
}
prepare_db() {
$run flask upgrade
}
gunicorn_run() {
$run gunicorn yadc:app
}
case $1 in
"init_venv")
prepare_venv
;;
"init_instance")
prepare_instance
;;
"init_db")
prepare_db
;;
"init")
prepare_venv
prepare_instance
prepare_db
;;
"run")
gunicorn_run
;;
"")
echo "useable parameters:"
echo " run - run gunicorn listener"
echo " init - complete init"
echo " init_venv"
echo " init_instance"
echo " init_db"
;;
esac

@ -70,8 +70,8 @@ class User(UserMixin, TimestampMixin, db.Model):
username = db.Column(db.String(128), unique=True, nullable=False)
email = db.Column(db.String(256), unique=True)
pass_hash = db.Column(db.String(128))
op_level = db.Column(db.Enum(OP_LEVEL), server_default=OP_LEVEL.user, nullable=False)
user_status = db.Column(db.Enum(USER_STATUS), server_default=USER_STATUS.active, nullable=False)
op_level = db.Column(db.Enum(OP_LEVEL), default=OP_LEVEL.user, nullable=False)
user_status = db.Column(db.Enum(USER_STATUS), default=USER_STATUS.active, nullable=False)
last_login = db.Column(UtcDateTime)
ban_status = None
@ -130,11 +130,11 @@ class Post(TimestampMixin, db.Model):
md5 = db.Column(db.String(32), unique=True, nullable=False)
filetype = db.Column(db.Enum(FILETYPE), nullable=False)
rating = db.Column(db.Enum(RATING), nullable=False)
status = db.Column(db.Enum(POST_STATUS), server_default=POST_STATUS.pending, nullable=False)
status = db.Column(db.Enum(POST_STATUS), default=POST_STATUS.pending, nullable=False)
width = db.Column(db.Integer, server_default=0)
height = db.Column(db.Integer, server_default=0)
filesize = db.Column(db.Integer, server_default=0)
width = db.Column(db.Integer, default=0)
height = db.Column(db.Integer, default=0)
filesize = db.Column(db.Integer, default=0)
source = db.Column(db.String(2048))
origin_filename = db.Column(db.String(255))
@ -227,7 +227,7 @@ class Post(TimestampMixin, db.Model):
class Tag(TimestampMixin, db.Model):
id = db.Column(db.Integer, primary_key=True)
content = db.Column(db.String(128), unique=True, nullable=False)
category = db.Column(db.Enum(TAG_CATEGORY), server_default=TAG_CATEGORY.general)
category = db.Column(db.Enum(TAG_CATEGORY), default=TAG_CATEGORY.general)
#posts = db.relationship('Post', secondary=post_tags, back_populates='tags')
@ -243,7 +243,7 @@ class Comment(TimestampMixin, db.Model):
content = db.Column(db.String(512), nullable=False)
# status = db.Column(db.Enum(COMMENT_STATUS), default=COMMENT_STATUS.visible)
deleted = db.Column(db.Boolean, server_default=False)
deleted = db.Column(db.Boolean, default=False)
delete_reason = db.Column(db.String(512))
post_id = db.Column(db.Integer, db.ForeignKey('post.id'))

Loading…
Cancel
Save