Libera la versión de desarrollo 0.0.2

This commit is contained in:
Manuel Cillero 2022-03-19 20:10:51 +01:00
parent 516d9683da
commit fbc6ab2adf
77 changed files with 651 additions and 161 deletions

View file

@ -0,0 +1,90 @@
use pagetop::db::migration::*;
/// Stores information about all defined {node} types.
#[derive(Iden)]
enum NodeType {
Table, // Nombre de la tabla: node_type (Tipo de nodo).
Type, // The machine-readable name of this type
Name, // The human-readable name of this type
Description, // Descripción breve del tipo.
Help, // Help information shown to the user when creating a {node} of this type
HasTitle, // Boolean indicating whether this type uses the {node}.title field
TitleLabel, // The label displayed for the title field on the edit form
Custom, // A boolean indicating whether this type is defined by a module (FALSE) or by a user via Add content type (TRUE)
Locked, // A boolean indicating whether the administrator can change the machine name of this type
Disabled, // A boolean indicating whether the node type is disabled
OrigType, // The original machine-readable name of this node type. This may be different from the current type name if the locked field is 0
}
pub struct Migration;
impl MigrationName for Migration {
fn name(&self) -> &str {
"m20220316_000001_create_table_node_type"
}
}
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_table(
Table::create()
.table(NodeType::Table)
.if_not_exists()
.col(ColumnDef::new(NodeType::Type)
.integer()
.not_null()
.auto_increment()
.primary_key(),
)
.col(ColumnDef::new(NodeType::Name)
.string()
.not_null()
)
.col(ColumnDef::new(NodeType::Description)
.string()
.not_null()
)
.col(ColumnDef::new(NodeType::Help)
.string()
.not_null()
)
.col(ColumnDef::new(NodeType::HasTitle)
.string()
.not_null()
)
.col(ColumnDef::new(NodeType::TitleLabel)
.string()
.not_null()
)
.col(ColumnDef::new(NodeType::Custom)
.string()
.not_null()
)
.col(ColumnDef::new(NodeType::Locked)
.string()
.not_null()
)
.col(ColumnDef::new(NodeType::Disabled)
.string()
.not_null()
)
.col(ColumnDef::new(NodeType::OrigType)
.string()
.not_null()
)
.to_owned()
)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_table(Table::drop()
.table(NodeType::Table)
.to_owned()
)
.await
}
}

View file

@ -0,0 +1,110 @@
use pagetop::db::migration::*;
/// The base table for nodes.
#[derive(Iden)]
enum Node {
Table, // Nombre de la tabla: node (Nodo).
Nid, // The primary identifier for a node
Vid, // The current {node_revision}.vid version identifier
Type, // The {node_type}.type of this node
Language, // The {languages}.language of this node
Title, // The title of this node, always treated as non-markup plain text
Uid, // The {users}.uid that owns this node; initially, this is the user that created it
Status, // Boolean indicating whether the node is published (visible to non-administrators)
Created, // The Unix timestamp when the node was created
Changed, // The Unix timestamp when the node was most recently saved
Comment, // Whether comments are allowed on this node: 0 = no, 1 = closed (read only), 2 = open (read/write)
Promote, // Boolean indicating whether the node should be displayed on the front page
Sticky, // Boolean indicating whether the node should be displayed at the top of lists in which it appears
Tnid, // The translation set id for this node, which equals the node id of the source post in each set
Translate, // A boolean indicating whether this translation page needs to be updated
}
pub struct Migration;
impl MigrationName for Migration {
fn name(&self) -> &str {
"m20220316_000002_create_table_node"
}
}
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_table(
Table::create()
.table(Node::Table)
.if_not_exists()
.col(ColumnDef::new(Node::Nid)
.integer()
.not_null()
.auto_increment()
.primary_key(),
)
.col(ColumnDef::new(Node::Vid)
.string()
.not_null()
)
.col(ColumnDef::new(Node::Type)
.string()
.not_null()
)
.col(ColumnDef::new(Node::Language)
.string()
.not_null()
)
.col(ColumnDef::new(Node::Title)
.string()
.not_null()
)
.col(ColumnDef::new(Node::Uid)
.string()
.not_null()
)
.col(ColumnDef::new(Node::Status)
.string()
.not_null()
)
.col(ColumnDef::new(Node::Created)
.string()
.not_null()
)
.col(ColumnDef::new(Node::Changed)
.string()
.not_null()
)
.col(ColumnDef::new(Node::Comment)
.string()
.not_null()
)
.col(ColumnDef::new(Node::Promote)
.string()
.not_null()
)
.col(ColumnDef::new(Node::Sticky)
.string()
.not_null()
)
.col(ColumnDef::new(Node::Tnid)
.string()
.not_null()
)
.col(ColumnDef::new(Node::Translate)
.string()
.not_null()
)
.to_owned()
)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_table(Table::drop()
.table(Node::Table)
.to_owned()
)
.await
}
}

View file

@ -0,0 +1,70 @@
use pagetop::db::migration::*;
// Identifies which realm/grant pairs a user must possess in order to view, update, or delete specific nodes.
#[derive(Iden)]
enum NodeAccess {
Table, // Nombre de la tabla: node_access (Acceso a nodos).
Nid, // The {node}.nid this record affects
Gid, // The grant ID a user must possess in the specified realm to gain this row's privileges on the node
Realm, // The realm in which the user must possess the grant ID. Each node access node can define one or more realms
GrantView, // Boolean indicating whether a user with the realm/grant pair can view this node
GrantUpdate, // Boolean indicating whether a user with the realm/grant pair can edit this node
GrantDelete, // Boolean indicating whether a user with the realm/grant pair can delete this node
}
pub struct Migration;
impl MigrationName for Migration {
fn name(&self) -> &str {
"m20220316_000003_create_table_node_access"
}
}
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_table(
Table::create()
.table(NodeAccess::Table)
.if_not_exists()
.col(ColumnDef::new(NodeAccess::Nid)
.integer()
.not_null()
.auto_increment()
.primary_key(),
)
.col(ColumnDef::new(NodeAccess::Gid)
.string()
.not_null()
)
.col(ColumnDef::new(NodeAccess::Realm)
.string()
.not_null()
)
.col(ColumnDef::new(NodeAccess::GrantView)
.string()
.not_null()
)
.col(ColumnDef::new(NodeAccess::GrantUpdate)
.string()
.not_null()
)
.col(ColumnDef::new(NodeAccess::GrantDelete)
.string()
.not_null()
)
.to_owned()
)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_table(Table::drop()
.table(NodeAccess::Table)
.to_owned()
)
.await
}
}

View file

@ -0,0 +1,90 @@
use pagetop::db::migration::*;
// Stores information about each saved version of a {node}.
#[derive(Iden)]
enum NodeRevision {
Table, // Nombre de la tabla: node_revisión (Versiones de nodos).
Nid, // The {node} this version belongs to
Vid, // The primary identifier for this version
Uid, // The {users}.uid that created this version
Title, // The title of this version
Log, // The log entry explaining the changes in this version
Timestamp, // A Unix timestamp indicating when this version was created
Status, // Boolean indicating whether the node (at the time of this revision) is published (visible to non-administrators)
Comment, // Whether comments are allowed on this node (at the time of this revision): 0 = no, 1 = closed (read only), 2 = open (read/write)
Promote, // Boolean indicating whether the node (at the time of this revision) should be displayed on the front page
Sticky, // Boolean indicating whether the node (at the time of this revision) should be displayed at the top of lists in which it appears
}
pub struct Migration;
impl MigrationName for Migration {
fn name(&self) -> &str {
"m20220316_000004_create_table_node_revision"
}
}
#[async_trait::async_trait]
impl MigrationTrait for Migration {
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.create_table(
Table::create()
.table(NodeRevision::Table)
.if_not_exists()
.col(ColumnDef::new(NodeRevision::Nid)
.integer()
.not_null()
.auto_increment()
.primary_key(),
)
.col(ColumnDef::new(NodeRevision::Vid)
.string()
.not_null()
)
.col(ColumnDef::new(NodeRevision::Uid)
.string()
.not_null()
)
.col(ColumnDef::new(NodeRevision::Title)
.string()
.not_null()
)
.col(ColumnDef::new(NodeRevision::Log)
.string()
.not_null()
)
.col(ColumnDef::new(NodeRevision::Timestamp)
.string()
.not_null()
)
.col(ColumnDef::new(NodeRevision::Status)
.string()
.not_null()
)
.col(ColumnDef::new(NodeRevision::Comment)
.string()
.not_null()
)
.col(ColumnDef::new(NodeRevision::Promote)
.string()
.not_null()
)
.col(ColumnDef::new(NodeRevision::Sticky)
.string()
.not_null()
)
.to_owned()
)
.await
}
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
manager
.drop_table(Table::drop()
.table(NodeRevision::Table)
.to_owned()
)
.await
}
}

View file

@ -0,0 +1,4 @@
pub mod m20220316_000001_create_table_node_type;
pub mod m20220316_000002_create_table_node;
pub mod m20220316_000003_create_table_node_access;
pub mod m20220316_000004_create_table_node_revision;