mirror of
https://github.com/offen/website.git
synced 2024-11-22 09:00:28 +01:00
use mysql to work around psycopg2 issues in lambda
This commit is contained in:
parent
1c20b4ba58
commit
ad2a574338
@ -198,8 +198,7 @@ jobs:
|
|||||||
docker:
|
docker:
|
||||||
- image: circleci/python:3.6
|
- image: circleci/python:3.6
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_CONNECTION_STRING: postgres://circle:test@localhost:5432/circle_test?sslmode=disable
|
MYSQL_CONNECTION_STRING: mysql://root:circle@127.0.0.1:3306/circle
|
||||||
HASHED_PASSWORD: JDJhJDEwJGpFRXJMOVVSQndZQlFQNjkxallkZi53aGp1cDMvRW5maGUvakZleG1pWFlnWEVXcU93ODBp
|
|
||||||
JWT_PRIVATE_KEY: |-
|
JWT_PRIVATE_KEY: |-
|
||||||
-----BEGIN PRIVATE KEY-----
|
-----BEGIN PRIVATE KEY-----
|
||||||
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCzgU18PnRrpbVK
|
MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCzgU18PnRrpbVK
|
||||||
@ -239,10 +238,11 @@ jobs:
|
|||||||
a3B4L0waKzP5QWcO865n1HCUTnV+s4lNcphBDZCrSwTkXnVnQWVPCL7ssoQyM0u3
|
a3B4L0waKzP5QWcO865n1HCUTnV+s4lNcphBDZCrSwTkXnVnQWVPCL7ssoQyM0u3
|
||||||
HQIDAQAB
|
HQIDAQAB
|
||||||
-----END PUBLIC KEY-----
|
-----END PUBLIC KEY-----
|
||||||
- image: circleci/postgres:11.2-alpine
|
- image: circleci/mysql:5.7
|
||||||
environment:
|
environment:
|
||||||
- POSTGRES_USER=circle
|
- MYSQL_ROOT_PASSWORD=circle
|
||||||
- POSTGRES_PASSWORD=test
|
- MYSQL_DATABASE=circle
|
||||||
|
- MYSQL_HOST=127.0.0.1
|
||||||
working_directory: ~/offen/accounts
|
working_directory: ~/offen/accounts
|
||||||
steps:
|
steps:
|
||||||
- checkout:
|
- checkout:
|
||||||
@ -261,15 +261,15 @@ jobs:
|
|||||||
- ~/offen/accounts/venv
|
- ~/offen/accounts/venv
|
||||||
key: offen-accounts-{{ checksum "requirements.txt" }}-{{ checksum "requirements-dev.txt" }}
|
key: offen-accounts-{{ checksum "requirements.txt" }}-{{ checksum "requirements-dev.txt" }}
|
||||||
- run:
|
- run:
|
||||||
name: Waiting for Postgres to be ready
|
name: Waiting for MySQL to be ready
|
||||||
command: |
|
command: |
|
||||||
for i in `seq 1 10`;
|
for i in `seq 1 10`;
|
||||||
do
|
do
|
||||||
nc -z localhost 5432 && echo Success && exit 0
|
nc -z localhost 3306 && echo Success && exit 0
|
||||||
echo -n .
|
echo -n .
|
||||||
sleep 1
|
sleep 1
|
||||||
done
|
done
|
||||||
echo Failed waiting for Postgres && exit 1
|
echo Failed waiting for MySQL && exit 1
|
||||||
- run:
|
- run:
|
||||||
name: Run tests
|
name: Run tests
|
||||||
command: |
|
command: |
|
||||||
|
@ -6,7 +6,7 @@ from flask_admin import Admin
|
|||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.secret_key = environ.get("SESSION_SECRET")
|
app.secret_key = environ.get("SESSION_SECRET")
|
||||||
app.config["SQLALCHEMY_DATABASE_URI"] = environ.get("POSTGRES_CONNECTION_STRING")
|
app.config["SQLALCHEMY_DATABASE_URI"] = environ.get("MYSQL_CONNECTION_STRING")
|
||||||
db = SQLAlchemy(app)
|
db = SQLAlchemy(app)
|
||||||
|
|
||||||
from accounts.models import Account, User
|
from accounts.models import Account, User
|
||||||
|
@ -9,8 +9,8 @@ def generate_key():
|
|||||||
|
|
||||||
class Account(db.Model):
|
class Account(db.Model):
|
||||||
__tablename__ = "accounts"
|
__tablename__ = "accounts"
|
||||||
account_id = db.Column(db.String, primary_key=True, default=generate_key)
|
account_id = db.Column(db.String(36), primary_key=True, default=generate_key)
|
||||||
name = db.Column(db.String, nullable=False, unique=True)
|
name = db.Column(db.String(256), nullable=False, unique=True)
|
||||||
users = db.relationship("AccountUserAssociation", back_populates="account")
|
users = db.relationship("AccountUserAssociation", back_populates="account")
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
@ -19,9 +19,9 @@ class Account(db.Model):
|
|||||||
|
|
||||||
class User(db.Model):
|
class User(db.Model):
|
||||||
__tablename__ = "users"
|
__tablename__ = "users"
|
||||||
user_id = db.Column(db.String, primary_key=True, default=generate_key)
|
user_id = db.Column(db.String(36), primary_key=True, default=generate_key)
|
||||||
email = db.Column(db.String, nullable=False, unique=True)
|
email = db.Column(db.String(256), nullable=False, unique=True)
|
||||||
hashed_password = db.Column(db.String, nullable=False)
|
hashed_password = db.Column(db.String(256), nullable=False)
|
||||||
accounts = db.relationship(
|
accounts = db.relationship(
|
||||||
"AccountUserAssociation", back_populates="user", lazy="joined"
|
"AccountUserAssociation", back_populates="user", lazy="joined"
|
||||||
)
|
)
|
||||||
@ -40,9 +40,9 @@ class AccountUserAssociation(db.Model):
|
|||||||
|
|
||||||
id = db.Column(db.Integer, primary_key=True)
|
id = db.Column(db.Integer, primary_key=True)
|
||||||
|
|
||||||
user_id = db.Column(db.String, db.ForeignKey("users.user_id"), nullable=False)
|
user_id = db.Column(db.String(36), db.ForeignKey("users.user_id"), nullable=False)
|
||||||
account_id = db.Column(
|
account_id = db.Column(
|
||||||
db.String, db.ForeignKey("accounts.account_id"), nullable=False
|
db.String(36), db.ForeignKey("accounts.account_id"), nullable=False
|
||||||
)
|
)
|
||||||
|
|
||||||
user = db.relationship("User", back_populates="accounts")
|
user = db.relationship("User", back_populates="accounts")
|
||||||
|
@ -6,5 +6,6 @@ werkzeug==0.15.4
|
|||||||
pyjwt[crypto]==1.7.1
|
pyjwt[crypto]==1.7.1
|
||||||
passlib==1.7.1
|
passlib==1.7.1
|
||||||
bcrypt==3.1.7
|
bcrypt==3.1.7
|
||||||
psycopg2==2.8.3
|
PyMySQL==0.9.3
|
||||||
|
mysqlclient
|
||||||
requests==2.22.0
|
requests==2.22.0
|
||||||
|
@ -25,9 +25,12 @@ services:
|
|||||||
POSTGRES_PASSWORD: develop
|
POSTGRES_PASSWORD: develop
|
||||||
|
|
||||||
accounts_database:
|
accounts_database:
|
||||||
image: postgres:11.2
|
image: mysql:5.7
|
||||||
|
ports:
|
||||||
|
- "3306:3306"
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_PASSWORD: develop
|
MYSQL_DATABASE: mysql
|
||||||
|
MYSQL_ROOT_PASSWORD: develop
|
||||||
|
|
||||||
server:
|
server:
|
||||||
build:
|
build:
|
||||||
@ -116,7 +119,7 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
FLASK_APP: accounts:app
|
FLASK_APP: accounts:app
|
||||||
FLASK_ENV: development
|
FLASK_ENV: development
|
||||||
POSTGRES_CONNECTION_STRING: postgres://postgres:develop@accounts_database:5432/postgres?sslmode=disable
|
MYSQL_CONNECTION_STRING: mysql+pymysql://root:develop@accounts_database:3306/mysql
|
||||||
CORS_ORIGIN: http://localhost:9977
|
CORS_ORIGIN: http://localhost:9977
|
||||||
SERVER_HOST: http://server:8080
|
SERVER_HOST: http://server:8080
|
||||||
SESSION_SECRET: vndJRFJTiyjfgtTF
|
SESSION_SECRET: vndJRFJTiyjfgtTF
|
||||||
|
Loading…
Reference in New Issue
Block a user