kinda working safe point
This commit is contained in:
parent
b9a82af12f
commit
6dda02141e
31 changed files with 4302 additions and 2937 deletions
36
app/migrations/add_share_table.py
Normal file
36
app/migrations/add_share_table.py
Normal file
|
@ -0,0 +1,36 @@
|
|||
"""
|
||||
Add Share table for file and folder sharing
|
||||
"""
|
||||
from sqlalchemy import inspect
|
||||
from .. import db
|
||||
|
||||
class AddShareTable:
|
||||
"""Migration to add the shares table"""
|
||||
version = 2
|
||||
description = "Add Share table for file/folder sharing"
|
||||
|
||||
def should_run(self, inspector):
|
||||
"""Check if the shares table exists"""
|
||||
return 'shares' not in inspector.get_table_names()
|
||||
|
||||
def run(self):
|
||||
"""Create the shares table"""
|
||||
try:
|
||||
db.engine.execute('''
|
||||
CREATE TABLE shares (
|
||||
id INTEGER PRIMARY KEY,
|
||||
item_type VARCHAR(10) NOT NULL,
|
||||
item_id INTEGER NOT NULL,
|
||||
owner_id INTEGER NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
permission VARCHAR(10) NOT NULL DEFAULT 'view',
|
||||
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
FOREIGN KEY (owner_id) REFERENCES users (id),
|
||||
FOREIGN KEY (user_id) REFERENCES users (id)
|
||||
)
|
||||
''')
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"Error creating shares table: {str(e)}")
|
||||
return False
|
Loading…
Add table
Add a link
Reference in a new issue