Skip to content

Commit 7f324ef

Browse files
initial implementation
1 parent 8f89000 commit 7f324ef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+6765
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
__pycache__
2+
*.pyc
3+
*.pyo
4+
*.pyd
5+
.Python
6+
*.so
7+
*.egg
8+
*.egg-info
9+
dist
10+
build
11+
.env
12+
.env.*
13+
!.env.example
14+
.venv
15+
venv
16+
ENV
17+
env
18+
.pytest_cache
19+
.mypy_cache
20+
.ruff_cache
21+
.coverage
22+
htmlcov
23+
*.log
24+
.git
25+
.gitignore
26+
README.md
27+
*.md
28+
tests
29+
.vscode
30+
.idea
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
[style]
2+
based_on_style = pep8
3+
column_limit = 82
4+
indent_width = 4
5+
continuation_indent_width = 4
6+
indent_closing_brackets = false
7+
dedent_closing_brackets = true
8+
indent_blank_lines = false
9+
spaces_before_comment = 2
10+
spaces_around_power_operator = false
11+
spaces_around_default_or_named_assign = true
12+
space_between_ending_comma_and_closing_bracket = false
13+
space_inside_brackets = false
14+
spaces_around_subscript_colon = true
15+
blank_line_before_nested_class_or_def = false
16+
blank_line_before_class_docstring = false
17+
blank_lines_around_top_level_definition = 2
18+
blank_lines_between_top_level_imports_and_variables = 2
19+
blank_line_before_module_docstring = false
20+
split_before_logical_operator = true
21+
split_before_first_argument = true
22+
split_before_named_assigns = true
23+
split_complex_comprehension = true
24+
split_before_expression_after_opening_paren = false
25+
split_before_closing_bracket = true
26+
split_all_comma_separated_values = true
27+
split_all_top_level_comma_separated_values = false
28+
coalesce_brackets = false
29+
each_dict_entry_on_separate_line = true
30+
allow_multiline_lambdas = false
31+
allow_multiline_dictionary_keys = false
32+
split_penalty_import_names = 0
33+
join_multiple_lines = false
34+
align_closing_bracket_with_visual_indent = true
35+
arithmetic_precedence_indication = false
36+
split_penalty_for_added_line_split = 275
37+
use_tabs = false
38+
split_before_dot = false
39+
split_arguments_when_comma_terminated = true
40+
i18n_function_call = ['_', 'N_', 'gettext', 'ngettext']
41+
i18n_comment = ['# Translators:', '# i18n:']
42+
split_penalty_comprehension = 80
43+
split_penalty_after_opening_bracket = 280
44+
split_penalty_before_if_expr = 0
45+
split_penalty_bitwise_operator = 290
46+
split_penalty_logical_operator = 0
Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# A generic, single database configuration.
2+
3+
[alembic]
4+
# path to migration scripts.
5+
# this is typically a path given in POSIX (e.g. forward slashes)
6+
# format, relative to the token %(here)s which refers to the location of this
7+
# ini file
8+
script_location = %(here)s/alembic
9+
10+
# template used to generate migration file names; The default value is %%(rev)s_%%(slug)s
11+
# Uncomment the line below if you want the files to be prepended with date and time
12+
# see https://alembic.sqlalchemy.org/en/latest/tutorial.html#editing-the-ini-file
13+
# for all available tokens
14+
# file_template = %%(year)d_%%(month).2d_%%(day).2d_%%(hour).2d%%(minute).2d-%%(rev)s_%%(slug)s
15+
16+
# sys.path path, will be prepended to sys.path if present.
17+
# defaults to the current working directory. for multiple paths, the path separator
18+
# is defined by "path_separator" below.
19+
prepend_sys_path = .
20+
21+
22+
# timezone to use when rendering the date within the migration file
23+
# as well as the filename.
24+
# If specified, requires the tzdata library which can be installed by adding
25+
# `alembic[tz]` to the pip requirements.
26+
# string value is passed to ZoneInfo()
27+
# leave blank for localtime
28+
# timezone =
29+
30+
# max length of characters to apply to the "slug" field
31+
# truncate_slug_length = 40
32+
33+
# set to 'true' to run the environment during
34+
# the 'revision' command, regardless of autogenerate
35+
# revision_environment = false
36+
37+
# set to 'true' to allow .pyc and .pyo files without
38+
# a source .py file to be detected as revisions in the
39+
# versions/ directory
40+
# sourceless = false
41+
42+
# version location specification; This defaults
43+
# to <script_location>/versions. When using multiple version
44+
# directories, initial revisions must be specified with --version-path.
45+
# The path separator used here should be the separator specified by "path_separator"
46+
# below.
47+
# version_locations = %(here)s/bar:%(here)s/bat:%(here)s/alembic/versions
48+
49+
# path_separator; This indicates what character is used to split lists of file
50+
# paths, including version_locations and prepend_sys_path within configparser
51+
# files such as alembic.ini.
52+
# The default rendered in new alembic.ini files is "os", which uses os.pathsep
53+
# to provide os-dependent path splitting.
54+
#
55+
# Note that in order to support legacy alembic.ini files, this default does NOT
56+
# take place if path_separator is not present in alembic.ini. If this
57+
# option is omitted entirely, fallback logic is as follows:
58+
#
59+
# 1. Parsing of the version_locations option falls back to using the legacy
60+
# "version_path_separator" key, which if absent then falls back to the legacy
61+
# behavior of splitting on spaces and/or commas.
62+
# 2. Parsing of the prepend_sys_path option falls back to the legacy
63+
# behavior of splitting on spaces, commas, or colons.
64+
#
65+
# Valid values for path_separator are:
66+
#
67+
# path_separator = :
68+
# path_separator = ;
69+
# path_separator = space
70+
# path_separator = newline
71+
#
72+
# Use os.pathsep. Default configuration used for new projects.
73+
path_separator = os
74+
75+
# set to 'true' to search source files recursively
76+
# in each "version_locations" directory
77+
# new in Alembic version 1.10
78+
# recursive_version_locations = false
79+
80+
# the output encoding used when revision files
81+
# are written from script.py.mako
82+
# output_encoding = utf-8
83+
84+
# database URL. This is consumed by the user-maintained env.py script only.
85+
# other means of configuring database URLs may be customized within the env.py
86+
# file.
87+
# sqlalchemy.url = driver://user:pass@localhost/dbname
88+
89+
90+
[post_write_hooks]
91+
# post_write_hooks defines scripts or Python functions that are run
92+
# on newly generated revision scripts. See the documentation for further
93+
# detail and examples
94+
95+
# format using "black" - use the console_scripts runner, against the "black" entrypoint
96+
# hooks = black
97+
# black.type = console_scripts
98+
# black.entrypoint = black
99+
# black.options = -l 79 REVISION_SCRIPT_FILENAME
100+
101+
# lint with attempts to fix using "ruff" - use the module runner, against the "ruff" module
102+
# hooks = ruff
103+
# ruff.type = module
104+
# ruff.module = ruff
105+
# ruff.options = check --fix REVISION_SCRIPT_FILENAME
106+
107+
# Alternatively, use the exec runner to execute a binary found on your PATH
108+
# hooks = ruff
109+
# ruff.type = exec
110+
# ruff.executable = ruff
111+
# ruff.options = check --fix REVISION_SCRIPT_FILENAME
112+
113+
# Logging configuration. This is also consumed by the user-maintained
114+
# env.py script only.
115+
[loggers]
116+
keys = root,sqlalchemy,alembic
117+
118+
[handlers]
119+
keys = console
120+
121+
[formatters]
122+
keys = generic
123+
124+
[logger_root]
125+
level = WARNING
126+
handlers = console
127+
qualname =
128+
129+
[logger_sqlalchemy]
130+
level = WARNING
131+
handlers =
132+
qualname = sqlalchemy.engine
133+
134+
[logger_alembic]
135+
level = INFO
136+
handlers =
137+
qualname = alembic
138+
139+
[handler_console]
140+
class = StreamHandler
141+
args = (sys.stderr,)
142+
level = NOTSET
143+
formatter = generic
144+
145+
[formatter_generic]
146+
format = %(levelname)-5.5s [%(name)s] %(message)s
147+
datefmt = %H:%M:%S
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Generic single database configuration
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
"""
2+
ⒸAngelaMos | 2025
3+
Alembic environment configuration for SQLModel migrations
4+
"""
5+
6+
from logging.config import fileConfig
7+
8+
from sqlalchemy import engine_from_config, pool
9+
from sqlmodel import SQLModel
10+
11+
from alembic import context
12+
from app.config import settings
13+
14+
# Import all models so they're registered with SQLModel metadata
15+
from app.models.User import User # noqa: F401
16+
from app.models.Credential import Credential # noqa: F401
17+
from app.models.IdentityKey import IdentityKey # noqa: F401
18+
from app.models.SignedPrekey import SignedPrekey # noqa: F401
19+
from app.models.OneTimePrekey import OneTimePrekey # noqa: F401
20+
from app.models.RatchetState import RatchetState # noqa: F401
21+
from app.models.SkippedMessageKey import SkippedMessageKey # noqa: F401
22+
23+
24+
config = context.config
25+
26+
if config.config_file_name is not None:
27+
fileConfig(config.config_file_name)
28+
29+
target_metadata = SQLModel.metadata
30+
31+
config.set_main_option("sqlalchemy.url", str(settings.DATABASE_URL))
32+
33+
34+
def run_migrations_offline() -> None:
35+
"""
36+
Run migrations in offline mode
37+
"""
38+
url = config.get_main_option("sqlalchemy.url")
39+
context.configure(
40+
url = url,
41+
target_metadata = target_metadata,
42+
literal_binds = True,
43+
dialect_opts = {"paramstyle": "named"},
44+
)
45+
46+
with context.begin_transaction():
47+
context.run_migrations()
48+
49+
50+
def run_migrations_online() -> None:
51+
"""
52+
Run migrations in online mode
53+
"""
54+
connectable = engine_from_config(
55+
config.get_section(config.config_ini_section, {}),
56+
prefix = "sqlalchemy.",
57+
poolclass = pool.NullPool,
58+
)
59+
60+
with connectable.connect() as connection:
61+
context.configure(
62+
connection = connection,
63+
target_metadata = target_metadata
64+
)
65+
66+
with context.begin_transaction():
67+
context.run_migrations()
68+
69+
70+
if context.is_offline_mode():
71+
run_migrations_offline()
72+
else:
73+
run_migrations_online()
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
"""${message}
2+
3+
Revision ID: ${up_revision}
4+
Revises: ${down_revision | comma,n}
5+
Create Date: ${create_date}
6+
7+
"""
8+
from typing import Sequence, Union
9+
10+
from alembic import op
11+
import sqlalchemy as sa
12+
${imports if imports else ""}
13+
14+
# revision identifiers, used by Alembic.
15+
revision: str = ${repr(up_revision)}
16+
down_revision: Union[str, Sequence[str], None] = ${repr(down_revision)}
17+
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
18+
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
19+
20+
21+
def upgrade() -> None:
22+
"""Upgrade schema."""
23+
${upgrades if upgrades else "pass"}
24+
25+
26+
def downgrade() -> None:
27+
"""Downgrade schema."""
28+
${downgrades if downgrades else "pass"}

PROJECTS/encrypted-p2p-chat/backend/app/__init__.py

Whitespace-only changes.

PROJECTS/encrypted-p2p-chat/backend/app/api/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)